2006 Dec 20 3:14 PM
Dear experts,
I need help in the following requirement,
I have a prgram named "A" with values in the selection screen. I need to call the other transaction "B" in the background passing all the values to that selection screen B from selection screen "A"and exectute . After exection it should return back to program "A" with the values of internal table in the program "B".
can anyone pls send me a sample code or let me know how to accomplish this
thanks in advance
karthik
2006 Dec 20 3:17 PM
Check this out
Check this syntax,
Report <program1>
select-options : sel1 for ...,
sel2 for ....
Report <program2>.
SUBMIT <program1> WITH sel1 IN r_sel1
WITH sel2 IN r_sel2.
You should define r_sel1 and r_sel2 with the range of values that needs to be passed to the fields on selection screen.
2006 Dec 20 3:18 PM
Hello Karthick,
Check this code.
I have did this report to submit to reports and get the output list of the two reports.
REPORT ZV_06_026 .
*--- Type für Anwenderstatus Suchhilfe
TYPES: BEGIN OF TY_ESTAT,
STSMA TYPE TJ30-STSMA,
ESTAT TYPE TJ30-ESTAT,
TXT04 TYPE TJ30T-TXT04,
TXT30 TYPE TJ30T-TXT30,
END OF TY_ESTAT.
*--- Anwenderstatus für Projekte
DATA: G_T_ESTAT TYPE TABLE OF TY_ESTAT,
G_R_ESTAT TYPE TY_ESTAT,
BEGIN OF G_T_STATUS OCCURS 0,
PSPID LIKE PROJ-PSPID, "Projektdefinition
POSID LIKE PRPS-POSID, "PSP-Element
END OF G_T_STATUS.
*--- Interne Tabelle für Listausgabe
DATA:
BEGIN OF G_T_LISTE OCCURS 0,
PSPNR LIKE PROJ-PSPNR, "Projektdefinition (intern)
PSPID LIKE PROJ-PSPID, "Projektdefinition
POSID LIKE PRPS-POSID, "PSP-Element
POST1 LIKE PRPS-POST1, "Kurzbeschreibung
KSTAR LIKE COSS-KSTAR, "Kostenart "/&-neueneu
KTEXT LIKE CSKU-KTEXT, "Kostenarttext"/&-neueneu
PLAN LIKE COSS-WTG001,
OBLIGO LIKE COSS-WTG001,
IST LIKE COSS-WTG001,
PLAN_MINUS LIKE COSS-WTG001,
OBLIGO_INT LIKE COSS-WTG001,
IST_INT LIKE COSS-WTG001,
IST_LFD LIKE COSS-WTG001,
PSPXX(1),
PSPNN(23),
END OF G_T_LISTE.
TYPES:
TYPE_TEXTLINE(512).
DATA:
W_TEXTLINE TYPE TYPE_TEXTLINE.
DATA:
LT_LIST TYPE TABLE OF ABAPLIST,
LT_TXT TYPE TABLE OF TYPE_TEXTLINE.
TABLES: T2503,PRPS,TJ02T.
SELECT-OPTIONS: SO_WWSTO FOR T2503-WWSTO.
*--- Buchungsperiod VON
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(33) TEXT-S01 FOR FIELD PA_JAHRV.
PARAMETERS:
PA_JAHRV TYPE GJAHR OBLIGATORY,
PA_PERV TYPE CO_PERIO OBLIGATORY.
SELECTION-SCREEN END OF LINE.
*--- Buchungsperiod BIS
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(33) TEXT-S02 FOR FIELD PA_JAHRB.
PARAMETERS:
PA_JAHRB TYPE GJAHR OBLIGATORY,
PA_PERB TYPE CO_PERIO OBLIGATORY.
SELECTION-SCREEN END OF LINE.
*--- Systemstatus
SELECT-OPTIONS: SO_PBUKR FOR PRPS-PBUKR DEFAULT '1060',
SO_ISTAT FOR TJ02T-TXT04 NO INTERVALS MATCHCODE OBJECT Z48R_ISTAT.
SELECTION-SCREEN BEGIN OF BLOCK BLCK2 WITH FRAME TITLE TEXT-002.
PARAMETERS: FILENAME LIKE RLGRAP-FILENAME
DEFAULT '
SI39467atmo2$SAMQFETRANSFER.txt'.
*SELECTION-SCREEN SKIP.
SELECTION-SCREEN ULINE.
PARAMETERS: AP RADIOBUTTON GROUP GRP1,
PC RADIOBUTTON GROUP GRP1.
SELECTION-SCREEN END OF BLOCK BLCK2.
*--- Initialzation -
*
INITIALIZATION.
PERFORM F_INITIALZATION.
*----
*
INCLUDE Z48C_PSP_DOWN_E01 *
*----
*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILENAME.
PERFORM FRONTEND_FILE CHANGING FILENAME.
*&----
*
*& Form f_initialzation
*&----
*
text
*----
*
--> p1 text
<-- p2 text
*----
*
FORM F_INITIALZATION.
PA_JAHRV = '1900'.
PA_PERV = '001'.
PA_JAHRB = SY-DATUM+0(4).
PA_PERB = SY-DATUM+4(2).
*--- Alle zu Projekten gehörene Anwenderstatus selektieren
SELECT TJ30STSMA TJ30ESTAT TJ30TTXT04 TJ30TTXT30
INTO CORRESPONDING FIELDS OF TABLE G_T_ESTAT
FROM TJ30
INNER JOIN TJ30T ON TJ30STSMA = TJ30TSTSMA
AND TJ30ESTAT = TJ30TESTAT
INNER JOIN TJ21 ON TJ30STSMA = TJ21STSMA
WHERE TJ30T~SPRAS EQ SY-LANGU
AND TJ21~OBTYP = 'PRN'
OR TJ21~OBTYP = 'PDN'.
ENDFORM. " f_initialzation
START-OF-SELECTION.
DATA: LISTOBJECT LIKE ABAPLIST OCCURS 0 WITH HEADER LINE.
SUBMIT Z48R_PROJEKTSTATUS WITH SO_WWSTO IN SO_WWSTO
WITH SO_ISTAT IN SO_ISTAT
EXPORTING LIST TO MEMORY
AND RETURN.
Import the list from memory and store it in table listobject
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
LISTOBJECT = LISTOBJECT
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
WRITE 'Error in list_from_memory.'.
ENDIF.
CALL FUNCTION 'LIST_TO_ASCI'
EXPORTING
LIST_INDEX = -1
TABLES
LISTASCI = LT_TXT
LISTOBJECT = LISTOBJECT
EXCEPTIONS
EMPTY_LIST = 1
LIST_INDEX_INVALID = 2
OTHERS = 3.
CHECK SY-SUBRC = 0.
DATA: LV_LINES LIKE SY-TABIX.
DESCRIBE TABLE LT_TXT LINES LV_LINES.
LOOP AT LT_TXT INTO W_TEXTLINE.
CHECK SY-TABIX > 3.
CHECK W_TEXTLINE(5) <> 'Keine'.
CHECK W_TEXTLINE(5) <> '-----'.
DO 120 TIMES. REPLACE ' |' WITH '|' INTO W_TEXTLINE. ENDDO.
"WRITE / w_textline(255).
PERFORM HANDLE_LINE USING W_TEXTLINE.
ENDLOOP.
Free memory
CALL FUNCTION 'LIST_FREE_MEMORY'
TABLES
LISTOBJECT = LISTOBJECT
EXCEPTIONS
OTHERS = 1.
IF SY-SUBRC <> 0.
WRITE 'Error in list_free_memory.'.
ENDIF.
**********************************************************
DATA: SO_PROJ TYPE RANGE OF PROJ-PSPID,
WA_PROJ LIKE LINE OF SO_PROJ,
SO_POSID TYPE RANGE OF PRPS-POSID,
WA_POSID LIKE LINE OF SO_POSID.
CLEAR: SO_PROJ,WA_PROJ,SO_POSID,WA_POSID.
REFRESH: SO_PROJ,SO_POSID.
LOOP AT G_T_STATUS.
WA_PROJ-SIGN = 'I'.
WA_PROJ-OPTION = 'EQ'.
WA_PROJ-LOW = G_T_STATUS-PSPID.
APPEND WA_PROJ TO SO_PROJ.
WA_POSID-SIGN = 'I'.
WA_POSID-OPTION = 'EQ'.
WA_POSID-LOW = G_T_STATUS-POSID.
APPEND WA_POSID TO SO_POSID.
CLEAR: WA_PROJ,WA_POSID.
ENDLOOP.
SORT SO_PROJ BY LOW.
DELETE ADJACENT DUPLICATES FROM SO_PROJ COMPARING LOW.
SORT SO_POSID BY LOW.
DELETE ADJACENT DUPLICATES FROM SO_POSID COMPARING LOW.
SUBMIT Z48R_PROJEKT_FEHLERKOSTEN WITH SO_PROJ IN SO_PROJ
WITH SO_PSP IN SO_POSID
WITH SO_PBUKR IN SO_PBUKR
WITH PA_JAHRV EQ PA_JAHRV
WITH PA_PERV EQ PA_PERV
WITH PA_JAHRB EQ PA_JAHRV
WITH PA_PERB EQ PA_PERB
WITH P_LIST EQ 'X'
EXPORTING LIST TO MEMORY
AND RETURN.
IMPORT G_T_LISTE FROM MEMORY ID 'IV_06_026'.
Import the list from memory and store it in table listobject
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
LISTOBJECT = LISTOBJECT
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
WRITE 'Error in list_from_memory.'.
ENDIF.
CALL FUNCTION 'LIST_TO_ASCI'
EXPORTING
LIST_INDEX = -1
TABLES
LISTASCI = LT_TXT
LISTOBJECT = LISTOBJECT
EXCEPTIONS
EMPTY_LIST = 1
LIST_INDEX_INVALID = 2
OTHERS = 3.
LOOP AT G_T_LISTE.
WRITE:/ G_T_LISTE.
ENDLOOP.
**********************************************************
*&----
*
*& Form handle_line
*&----
*
text
*----
*
<--> P_TEXTLINE text
*----
*
FORM HANDLE_LINE USING P_LINE.
DATA: BEGIN OF T_CLINE OCCURS 0,
TEXT(40),
END OF T_CLINE.
erstes Zeichen immer | und irrelevant
SHIFT P_LINE.
SPLIT P_LINE AT '|' INTO TABLE T_CLINE.
READ TABLE T_CLINE INDEX 2.
G_T_STATUS-PSPID = T_CLINE-TEXT.
READ TABLE T_CLINE INDEX 3.
G_T_STATUS-POSID = T_CLINE-TEXT.
APPEND G_T_STATUS.
ENDFORM. " handle_line
*&----
*
*& Form HANDLE_LINE_LIST
*&----
*
text
*----
*
-->P_W_TEXTLINE text
*----
*
FORM HANDLE_LINE_LIST USING P_LINE.
DATA: BEGIN OF T_CLINE OCCURS 0,
TEXT(40),
END OF T_CLINE.
erstes Zeichen immer | und irrelevant
SHIFT P_LINE.
SPLIT P_LINE AT '|' INTO TABLE T_CLINE.
READ TABLE T_CLINE INDEX 2.
G_T_OUTTAB-PSPID = T_CLINE-TEXT.
READ TABLE T_CLINE INDEX 3.
G_T_OUTTAB-POSID = T_CLINE-TEXT.
APPEND G_T_OUTTAB.
ENDFORM. " HANDLE_LINE_LIST
*&----
*
*& Form frontend_file
*&----
*
text
*----
*
<--P_FILENAME text
*----
*
FORM FRONTEND_FILE CHANGING P_FILENAME.
CALL FUNCTION '/SAPDMC/LSM_F4_FRONTEND_FILE'
EXPORTING
PATHNAME = 'C:'
CHANGING
PATHFILE = P_FILENAME
EXCEPTIONS
CANCELED_BY_USER = 1
SYSTEM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " frontend_file
Hope this will helps you.
Vasanth
2006 Dec 20 4:22 PM
Dear Vasanth,
Thank you for timely reply. i used your logic from your program .
but i am getting the below result
The called program report is displaying without the returning to the calling program, if i press the back butoon i see the error stating that
Error in list_from_memory from the function module List_from_memory.
2006 Dec 20 4:28 PM
2006 Dec 20 4:37 PM
Dear Vasanth,
This is my code,
TABLES: mhis,
mpos,
mhio,
iloa,
vimhio,
iflos,
t351,
t351p,
t351t.
TYPES: TYPE_TEXTLINE(512).
DATA: W_TEXTLINE TYPE TYPE_TEXTLINE.
data : LT_LIST TYPE TABLE OF ABAPLIST,
LT_TXT TYPE TABLE OF TYPE_TEXTLINE.
*internal tables
DATA : BEGIN OF i_mhis OCCURS 0,
warpl LIKE mhis-warpl,
abnum LIKE mhis-abnum,
zaehl LIKE mhis-zaehl,
zykzt LIKE mhis-zykzt,
tstat LIKE mhis-tstat,
pstxt LIKE mpos-pstxt,
plnnr LIKE mpos-plnnr,
plnal LIKE mpos-plnal,
END OF i_mhis.
DATA : BEGIN OF i_mhio OCCURS 0,
warpl LIKE mhio-warpl,
aufnr LIKE mhio-aufnr,
addat LIKE mhio-addat,
gstrp LIKE mhio-gstrp,
END OF i_mhio.
DATA : BEGIN OF i_iflos OCCURS 0,
tplnr LIKE iflos-tplnr,
strno LIKE iflos-strno,
END OF i_iflos.
DATA : BEGIN OF i_iloa OCCURS 0,
aufnr LIKE iloa-aufnr,
tplnr LIKE iloa-tplnr,
stort LIKE iloa-stort,
eqfnr LIKE iloa-eqfnr,
END OF i_iloa.
FINAL INTERNAL TABLE
DATA : BEGIN OF i_final OCCURS 0,
warpl LIKE mhis-warpl,
abnum LIKE mhis-abnum,
tstat LIKE mhis-tstat,
pstxt LIKE mpos-pstxt,
plnnr LIKE mpos-plnnr,
plnal LIKE mpos-plnal,
addat LIKE mhio-addat,
gstrp LIKE mhio-gstrp,
tplnr LIKE iflos-tplnr,
strno LIKE iflos-strno,
stort LIKE iloa-stort,
eqfnr LIKE iloa-eqfnr,
END OF i_final.
*ALV data declarations
TYPE-POOLS: slis. "ALV Declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid.
SELECTION-SCREEN BEGIN OF BLOCK m_plan WITH FRAME TITLE text-001.
SELECT-OPTIONS:
p_warpl FOR mhis-warpl,
p_pstxt FOR mpos-pstxt,
p_strno FOR iflos-strno MATCHCODE OBJECT iflm,
p_gstrp FOR mhio-gstrp,
p_addat FOR mhio-addat,
p_tstat FOR mhis-tstat,
p_plnnr FOR mpos-plnnr,
p_plnal FOR mpos-plnal,
p_stort FOR iloa-stort ,
p_eqfnr FOR iloa-eqfnr.
SELECTION-SCREEN END OF BLOCK m_plan.
All operation
SELECTION-SCREEN BEGIN OF BLOCK operation WITH FRAME TITLE text-002.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS screen1 RADIOBUTTON GROUP strt DEFAULT 'X'.
SELECTION-SCREEN COMMENT 04(30) text-002.
SELECTION-SCREEN POSITION 45.
PARAMETERS screen2 RADIOBUTTON GROUP strt.
SELECTION-SCREEN COMMENT 48(30) text-003.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK operation.
layout
SELECTION-SCREEN BEGIN OF BLOCK layout WITH FRAME.
PARAMETERS: p_vari LIKE disvariant-variant.
SELECTION-SCREEN END OF BLOCK layout.
*Start-of-selection.
START-OF-SELECTION.
DATA: listobject LIKE abaplist OCCURS 0 WITH HEADER LINE.
SUBMIT rimhio00 WITH warpl IN p_warpl
WITH pstxt IN p_pstxt
EXPORTING LIST TO MEMORY
AND RETURN.
Import the list from memory and store it in table listobject
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = listobject
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
WRITE 'Error in list_from_memory.'.
ENDIF.
2006 Dec 20 4:51 PM
Hello,
Karthick,
I have tested ur report in my system. The submited reprot RIMHIO00 is not writing any list.
Thatswhy the FM is not able to capture any record.
Even I have tested this report and not dispalying and output.
I am sur if the any data is selected from RIMHIO00 then u will see it in ur report.
Vasanth
2006 Dec 20 5:09 PM
Dear vasanth,
i am getting the list from submited reprot RIMHIO00, to be clear
when i exectute my program with values in the selction screen, the RIMHIO00 program exectutes and displays the list with the values but it is not returning to my calling program.
2006 Dec 20 8:35 PM
Hello Karthick,
To be clear.
If u use the EXPORTING TO LIST AND RETURN then the listof the called program will not be displayed and the list will be exported to the memory.
Anyhow I came from the office. Tommorow I will check that and let you.
Vasanth
2006 Dec 21 8:18 AM
Dear Vasanth,
Thanks for your interest.
I tried calling other program, it is working. but for the program RIMHIO00 it is not working. i thought that for the interactive grid report this submit command is not useful. but i am not sure. pls check and let me know.
my requirement is i need to pass values to the program RIMHIO00 and executed and after execution i need the final internal table (object_tab) values in my program for further process.
other than this, pls send me a sample program to set layout in reusealvgriddisplay.
note i given points to u
thanks in advance.
2006 Dec 21 8:34 AM
Hello Karthick,
If the report produces the ALV grid then it is not possible to export the list.
Either the output should be a ordinary report or ALV List.
If it is a list we have to think some other possiblity.
Vasanth
2006 Dec 21 8:37 AM
Hi karthik,
just make a slight change in Sumbit statement as follows -
it will fulfill ur requirement -
SUBMIT RIMPLA00 WITH warpl IN p_warpl
WITH pstxt IN p_pstxt
EXPORTING LIST TO MEMORY
AND RETURN.
reward points if helpfull..
amit
2006 Dec 21 9:04 AM
Dear amith,
I am getting same output, the program is not returning to calling program
2006 Dec 21 9:12 AM
Hello Karthick,
There is user field in the report RIMHIO00 G_GRID.
Check the report where is field is set.
If you set this field through ur report then ur problem will be solved.
Since if G_GRID = 'X'. report is displaying the ALV list from which u could import the list.
If useful reward.
Vasanth
2006 Dec 21 9:28 AM
hi karthik ,
remove this part from ur code - (also submit would be with the report name which i gave u some time back)
Import the list from memory and store it in table listobject
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = listobject
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
WRITE 'Error in list_from_memory.'.
ENDIF.
it will work fine..
reward ptns if helpfull..
2006 Dec 21 9:59 AM
Dear vasanth,
I found below coding in the called program , but i don't know waht to do with this, pls guide me to get the solution
get parameter id 'Q_ALV_GRID_INACTIVE' field g_grid.
*--- call customer function to change ALV settings
call function 'IREP1_CHANGE_SETTINGS_ALV'
thanks in advance
2006 Dec 21 10:08 AM
Dear amit,
even if i remove that part i am getting same result.
my requirement is i want the final internal table values(object_tab) from the program RIMHIO00 in my calling program.
2006 Dec 20 3:18 PM
prg A
Submit b with selection-screen and return.
import itab from memory.
prg B
export itab to memory.
Basically you can submit program b with selection-screen parameters and return. While in Prg B you can Export the resultant internal table to memory. So on return to prg A you can import it from memory and use it.