‎2008 Apr 21 8:16 PM
Hi Experts,
I want to call two programs into main program.
Program1 having 5 fields on the selection screen and
Program2 is having 7 fields on the selection screen.
Main program selection screen is having three fields (three select-option fields), which are common selection fields in the program1 and program2.
My requirement is to pass the three selection screen fields from the main program to program1 and program2 and return some data say itab from program1 and say xtab from program2.
Please help me in writing a submit statement for this.
Regards,
Venkat
‎2008 Apr 21 11:09 PM
Hi Aman,
I did in the same way you described with an example in the above thread. Logic. But still it was displaying the program1 list output.
Actually the progra1 and program2 are two separate program with ALV list display.
Even I did in the same way as you given in the sample example, because the program1 is having ALV display statements;After submit statement in the main program it is printing the ALV of program1 and then it is coming back to the main program.
Regards,
Venkat
‎2008 Apr 21 8:29 PM
report main program
SUBMIT program1 USING SELECTION-SCREEN 'nnnn'
WITH SELECTION-TABLE rspar_tab1(selection parameter of main program)
WITH SELECTION-TABLE rspar_tab2(selection parameter of main program)
WITH SELECTION-TABLE rspar_tab3(selection parameter of main program) "same selection field for both the programs
WITH selcrit2 IN range_tab " for different field.
AND RETURN.
‎2008 Apr 21 8:31 PM
Try this.
>DATA: seltab LIKE rsparams OCCURS 0.
>
>AT SELECTION-SCREEN.
>* perform user-commands on screen
> CASE sy-ucomm.
>* Submit Report .
> WHEN 'SUBMIT'. "Submit Report
> CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
> EXPORTING
> curr_report = 'ZMAIN_PROGRAM'
> TABLES
> selection_table = seltab.
> SUBMIT zprogram1 AND RETURN WITH SELECTION-TABLE seltab.
> ENDCASE.
‎2008 Apr 21 8:43 PM
Hi Experts,
Can you explain in more detail please...
Regards,
Venkat
‎2008 Apr 21 8:56 PM
The seltab will have all the parameters from the main program and will be passed on to the next program which got submitted from it.
Other way you can export the parameters to memory and retrieve from another program.
PLease check statement EXPORT to MEMORY as well.
hope this helps.
A
‎2008 Apr 21 9:07 PM
Hi Aman,
Thank you very much for the quick response.
How to return the data from program1 and program2?
I need to consolidate the data of both the programs in the main program.
Regards,
Venkat
‎2008 Apr 21 9:34 PM
‎2008 Apr 21 9:44 PM
Hi Aman,
I did in the same way as you suggested.
I am able to read the internal table values from program1.
But it is displaying the program1 list output first, then the control is coming back to the main program with required data of program1.
I dont want to display the program1 output; I need only the data from it.
Regards,
Venkat
‎2008 Apr 21 9:54 PM
Try this way.
> SUBMIT zp_adp_number_check
> AND RETURN WITH SELECTION-TABLE seltab
> EXPORTING LIST TO MEMORY.
To retrieve the list u can use
>DATA list_tab TYPE TABLE OF abaplist.
>CALL FUNCTION 'LIST_FROM_MEMORY'
> TABLES
> listobject = list_tab
> EXCEPTIONS
> not_found = 1
> OTHERS = 2.
>
>IF sy-subrc = 0.
> CALL FUNCTION 'WRITE_LIST'
> TABLES
> listobject = list_tab.
>ENDIF.
‎2008 Apr 21 10:08 PM
Hi Aman,
The program is going to dump.
Please correct me if I am wrong from the following code:
SUBMIT program1 WITH s_matnr IN s_matnr
WITH s_ersda IN s_ersda
AND RETURN
EXPORTING LIST TO MEMORY.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = list_tab
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc = 0.
CALL FUNCTION 'WRITE_LIST'
TABLES
listobject = list_tab.
ENDIF.
Regards,
Venkat
‎2008 Apr 21 10:21 PM
Sample code.
REPORT 1.
REPORT zsubmit_main.
DATA: lv_pernr TYPE persno.
DATA: seltab LIKE rsparams OCCURS 0.
DATA: itab TYPE TABLE OF pa0000.
SELECT-OPTIONS pernr FOR lv_pernr.
CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
EXPORTING
curr_report = 'ZSUBMIT_MAIN'
TABLES
selection_table = seltab.
SUBMIT zsubmit_main1 AND RETURN WITH SELECTION-TABLE seltab .
IMPORT itab FROM MEMORY ID 'pernr'.
BREAK-POINT.
REPORT 2.
DATA: itab TYPE TABLE OF pa0000,
lv_pernr TYPE persno.
SELECT-OPTIONS pernr FOR lv_pernr.
BREAK-POINT.
SELECT * FROM pa0000 INTO TABLE itab WHERE pernr IN pernr.
EXPORT itab TO MEMORY ID 'pernr'.
‎2008 Apr 21 10:41 PM
Hi Aman,
Still It is displaynig the list output of the program1 before control goes to main program.
Can you correct me in the following code?
SUBMIT program1 WITH s_matnr IN s_matnr
WITH s_ersda IN s_ersda
AND RETURN
EXPORTING LIST TO MEMORY.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = list_tab
EXCEPTIONS
not_found = 1
OTHERS = 2.
Regards,
Venkat
‎2008 Apr 21 10:46 PM
Use my previous thread logic.
Thanks
A
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Apr 21, 2008 5:49 PM
‎2008 Apr 21 11:09 PM
Hi Aman,
I did in the same way you described with an example in the above thread. Logic. But still it was displaying the program1 list output.
Actually the progra1 and program2 are two separate program with ALV list display.
Even I did in the same way as you given in the sample example, because the program1 is having ALV display statements;After submit statement in the main program it is printing the ALV of program1 and then it is coming back to the main program.
Regards,
Venkat
‎2008 Apr 22 2:17 PM
If Program 2 is called from a submit statement from the main program, avoid printing. you can pass a flag which would assume this program is called from another program and you can avoid printing. If you need to retrieve the table of program 1 and 2 in main program use Export to memory statement. I hope this is clear.
A
‎2008 Apr 22 6:29 PM
Hi Aman,
It is working now.
Thank you very much for your quick response and for the perfect solution.
Regards,
Venkat