running sqr from front end and multiple reports

12
RUNNING SQR FROM FRONT END (N-TIER) 1. Make SQR program api aware - At start of program include ‘setenv.sqc’ - At the end of program section include ‘stdapi.sqc’ - Call procedure in program section Do stdapi-init Do stdapi-term at end of program section. 2. Copy the program to sqr folder 3. Create run control definition Insert subpage : PRCSRUNCNTL_SBP Save Run control component Drag and drop run control component Provide search record : PRCSRUNCNTL 4. Register component 5. Front end : provide any run cntrl id: 6. In process definition: People type : SQR reports Process name : provide the record name Process definition: Cmpnt: componenet name Process groups -> all panels, all groups Server name -> PSNT + unique process id Passing parameters (n-tier) 1. Create run control record OPRID -> key RUN_CNTL_ID -> KEY !! ALSO PROVIDE INPUT FIELD..! PEOPLE CODE: a) B55_sqr_Tbl : oprid-> rowinit b55_sqr_tbl.oprid.value= %operatorid;

Upload: shery2710

Post on 26-Nov-2014

108 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Running Sqr From Front End and Multiple Reports

RUNNING SQR FROM FRONT END (N-TIER)

1. Make SQR program api aware- At start of program include ‘setenv.sqc’- At the end of program section include ‘stdapi.sqc’- Call procedure in program section

Do stdapi-init Do stdapi-term at end of program section.

2. Copy the program to sqr folder3. Create run control definition

Insert subpage : PRCSRUNCNTL_SBP Save

Run control component

Drag and drop run control component Provide search record : PRCSRUNCNTL

4. Register component5. Front end : provide any run cntrl id:6. In process definition:

People type : SQR reports Process name : provide the record name Process definition:

Cmpnt: componenet nameProcess groups -> all panels, all groups

Server name -> PSNT + unique process id

Passing parameters (n-tier)

1. Create run control recordOPRID -> keyRUN_CNTL_ID -> KEY!! ALSO PROVIDE INPUT FIELD..!

PEOPLE CODE:

a) B55_sqr_Tbl : oprid-> rowinit b55_sqr_tbl.oprid.value=%operatorid;b) B55_sqr_tbl-> runcntl_id-> rowinit b55_sqr_tbl.run-

cntl_id.value=prcsruncntl_run_cntl_id_value;

Page 2: Running Sqr From Front End and Multiple Reports

2. Create run control page : b55_sqr_pga. Subpage -> prcsruncntl_sbp

Country3. Component : b55_sqr_cmpt

Page : provide page nameSearch rec: prcsruncntl

4. Register component5. Create sqr program6. Move sqr file to sqr folder7. Create process definition.8. Run SQR program9. Verify the status in process monitor

# include ‘setenv.sqc’

Begin-program

Do stdapi-init

Do get param

Do tab

Do stdapi-term

End-program

Begin-procedure getparam

Begin-select

Country

Move &country to $ cntry

From ps_b55_sqrtbl

Where oprid=$prcs_run_cntl_id

End-select

End-procedure

Begin procedure tab

Begin-select

Page 3: Running Sqr From Front End and Multiple Reports

Emplid (+1,1)

Name( ,15)

Country ( ,60)

From ps_employees

Where country= $cntry

End-select

End-procedure

#include ‘stdapi.sqc’

File handling/ file integration (outbound/ inbound integrate)

File handling commands

i) Open : This is used to open a file for reading/ writing or appendingii) Read: To read line-line data from file to a variableiii) Write: To write data from variables to a file.iv) Close : This is used to close the file which is open.

Page 4: Running Sqr From Front End and Multiple Reports

! outbound file integration

Begin-program

!let $writefile=’C:\temp\b55_sqr.txt’

let $writefile=’C:\temp\b55_sqr.csv’

open $writefile as 30 for-writing record =100 status =#filestatus

if file stat!=0

print ‘error in opening file’ (2,1)

else

do write_Data

close 30

print ‘writing data complete’ (1,1)

end-if

end-program

begin-procedure write_data

begin-select

emplid

name

country

monthly_rt

!write 30 from &emplid :10 &emplid:35 & country:5 &monthly_rt:10

Write 30 from &emplid’,’ &name ‘,’ &country ‘,’ &monthly_rt

From ps_employee

End-select

End-procedure

Page 5: Running Sqr From Front End and Multiple Reports

!inbound file-integration

BEGIN-SETUP

BEGIN-SQL

CREATE TABLE B55_TBL(DEPTID VARCHAR(2),EMPLID VARCHAR(#),NAME VARCHAR(20));

END-SQL

END-SETUP

BEGIN-PROGRAM

LET $READFILE=’C:\TEMP\B55_IP.TXT’

DO FILE HANDLING

CLOSE 30

END-PROGRAM

BEGIN-PROCEDURE FILEHANDLING

OPEN $READFILE AS 30 FOR READING RECORD=100 STATUS=#FILESTAT

IF #FILESTAT!=0

PRINT ‘ERROR IN OPENING FILE’ (2,1)

ELSE

WHILE 30

READ 30 INTO $LINE :100

UNSTRING $LINE BY ‘#’ INTO $DEPTID $EMPLID $NAME

DO INSERTION

IF #END-FILE

BREAK

END-IF

Page 6: Running Sqr From Front End and Multiple Reports

PRINT ‘READ DATA COMPLETED’(1,1)

END-PROCEDURE

BEGIN-PROCEDURE INSERTION

BEGIN-SQL

INSERT INTO B55_TBL(DEPTID,EMPLID,NAME)

VALUES($DEPTID,$EMPLID,$NAME);\

END-SQL

END-PROCEDURE

MULTIPLE REPORTS

This Is used to generate multiple outputs from the same data source.

Commands for multiple reports:

- DECLARE-LAYOUT

- DECLARE- REPORT

- FOR-REPORT

- USE-REPORT

DECLARE-LAYOUT

This is used to define the different output formats generated using the multiple reports.

This is used in Begin-Setup section.

Based on number of outputs generated, that many number of DECLARE-LAYOUT commands

must be written in the Begin-Setup section.

Syntax:

DECLARE-LAYOUT <Layout name>

Other commands

END-DECLARE

Page 7: Running Sqr From Front End and Multiple Reports

Example:

BEGIN-SETUP

DECLARE-LAYOUT EMPDET

#INCLUDE ‘setup02.sqc’

END-DECLARE

DECLARE-LAYOUT PAYSLIP

#INCLUDE ‘setup01.sqc’

END-DECLARE

DECLARE-LAYOUT EMPTAB

END-DECLARE

END-SETUP

DECLARE-REPORT:

This is used to assign the layout of the report.

This is used in Begin-Setup section.

Based on number of outputs generated, that many number of DECLARE-REPORT commands

must be written in the Begin-Setup section.

Syntax:

DECLARE-REPORT <Layout name>

LAYOUT= <layout name>

END-DECLARE

Example:

BEGIN-SETUP

Page 8: Running Sqr From Front End and Multiple Reports

DECLARE-REPORT EMPDET

LAYOUT= ‘EMPLDET’

END-DECLARE

DECLARE-REPORT PAYSLIP

LAYOUT= ‘PAYSLIP’

END-DECLARE

DECLARE-REPORT EMPTAB

LAYOUT= ‘EMPTAB’

END-DECLARE

END-SETUP

FOR-REPORT:

This is used to assign different heading and footing sections to different reports.

This is used in heading and footing sections.

Syntax:

BEGIN-HEADING/ FOOTING # FOR-REPORT <report name>

PRINT commands

END-HEADING/ FOOTING

Example:

BEGIN-HEADING 2 FOR REPORT = ‘EMPLDET’

Page 9: Running Sqr From Front End and Multiple Reports

PRINT ‘employee detail report’ (1, 20) BOLD BOX

PRINT ‘EID’ (2, 1) BOLD UNDERLINE

PRINT ‘NAME’ (2, 10) BOLD UNDERLINE

PRINT ‘SALARY’ (2, 40) BOLD UNDERLINE

PRINT ‘DOJ’ (2, 55) BOLD UNDERLINE

PRINT ‘COUNTRY’ (2, 70) BOLD UNDERLINE

END-HEADING

BEGIN-HEADING 2 FOR REPORT =’PAYSLIP’

PRINT ‘PAYSLIP’ (1, 15) BOLD BOX

END-HEADING

BEGIN-HEADING 2 FOR REPORT=’EMPTAB’

PRINT ‘EMPLID’ (1, 1) BOLD UNDERLINE

PRINT ‘NAME’ (1, 10) BOLD UNDERLINE

PRINT ‘AGE’ (1, 45) BOLD UNDERLINE

END-HEADING

BEGIN-FOOTING 1 FOR REPORT=’EMPLDET’

PRINT ‘** confidential information**’ (1, 10) BOLD

END-FOOTING

BEGIN-FOOTING 1 FOR REPORT=’PAYSLIP’

PRINT ‘Sign not required’ (1, 10) BOLD

END-FOOTING

USE-REPORT

Page 10: Running Sqr From Front End and Multiple Reports

This is used to assign different programs or procedure sections coding to the different reports.

This is used in program or procedure sections.

Syntax:

USE-REPORT <report name>

Commands

USE-REPORT <report name>

Commands

Example:

BEGIN-PROCEDURE PRINTING

USE-REPORT=’EMPLDET’

PRINT &EMPLID (+1, 1)

PRINT &NAME ( , 10)

PRINT &MONTHLY_RT ( , 40)

PRINT &HIRE_DT ( , 55)

PRINT &COUNTRY ( , 70)

USE-REPORT=’PAYSLIP ‘

PRINT ‘EMPLID : (1, 1)

PRINT ‘NAME : (3, 1)

PRINT ‘MNTHLY_RT : (5, 1)

PRINT &EMPLID (1 , 40)

PRINT &NAME ( 3, 40)

Page 11: Running Sqr From Front End and Multiple Reports

PRINT &MNTHLY_RT (5, 40)

NEW-PAGE

USE-REPORT=’EMPTAB’

PRINT &EMPLID (+1, 1)

PRINT &NAME ( ,10)

PRINT &AGE ( ,50)

END-PROCEDURE