‎2008 Aug 25 10:03 AM
Dear all,
I had a requirement,
I had 2 programs ZAR1 & ZAR2.
Both the programs has an internal table with following fields,
data begin of itab occurs 0,
matnr like mseg-matnr,
menge like mseg-menge,
meins like mseg-meins,
dmbtr like mseg-dmbtr,
end of itab.
My requirement is I will run the program ZAR1, it want to pass all the internal table values from ZAR1 into ZAR2 program.
regards
arun
‎2008 Aug 25 10:08 AM
Hi,
" In program ZAR1
EXPORT itab FROM itab TO MEMORY ID 'ZABC'.
" In program ZAR2
IMPORT itab TO itab FROM MEMORY ID 'ZABC'.
"Note:name and structure of the both internal table be same.Regards
Adil
‎2008 Aug 25 10:04 AM
Hi,
Use EXPORT/ IMPORT statements.
Have a look at these two sample programs.
I'm sending t_spfli table from Program 1 to program 2
PROGRAM 1
REPORT z_abap_memory.
DATA:
w_carrid TYPE spfli-carrid,
BEGIN OF fs_spfli,
carrid LIKE spfli-carrid,
connid LIKE spfli-connid,
fltime LIKE spfli-fltime,
END OF fs_spfli.
DATA:
t_spfli LIKE
TABLE OF
fs_spfli.
SELECT-OPTIONS:
s_carrid FOR w_carrid.
START-OF-SELECTION.
PERFORM get_spfli.
PERFORM disp_spfli.
AT LINE-SELECTION.
IF sy-lsind EQ 1.
EXPORT t_spfli TO MEMORY ID 'ABC'.
SUBMIT z_ABAP_MEMORY1 AND RETURN.
ENDIF.
END-OF-SELECTION.
PERFORM disp_spfli.
*&---------------------------------------------------------------------*
*& Form get_spfli
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_spfli .
SELECT carrid
connid
fltime
FROM spfli
INTO TABLE t_spfli
WHERE carrid IN s_carrid.
ENDFORM. " get_spfli
*&---------------------------------------------------------------------
*
*& Form disp_spfli
*&---------------------------------------------------------------------
*
* text
*----------------------------------------------------------------------
*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------
*
FORM disp_spfli .
LOOP AT t_spfli INTO fs_spfli.
WRITE: / fs_spfli-carrid,
fs_spfli-connid,
fs_spfli-fltime.
HIDE:
fs_spfli-carrid,
fs_spfli-connid.
ENDLOOP.
ENDFORM. " disp_spfli
PROGRAM 2
REPORT z_abap_memory1.
DATA:
BEGIN OF fs_spfli,
carrid LIKE spfli-carrid,
connid LIKE spfli-connid,
fltime LIKE spfli-fltime,
END OF fs_spfli,
fs_fl LIKE fs_spfli.
DATA:
BEGIN OF fs_flight,
carrid LIKE sflight-carrid,
connid LIKE sflight-connid,
fldate LIKE sflight-fldate,
END OF fs_flight.
DATA:
t_spfli LIKE
TABLE OF
fs_spfli.
DATA:
t_fl LIKE t_spfli.
DATA:
t_flight LIKE
TABLE OF
fs_flight.
IMPORT t_spfli FROM MEMORY ID 'ABC'.
t_fl = t_spfli.
SELECT carrid
connid
fldate
FROM sflight
INTO TABLE t_flight
FOR ALL ENTRIES IN t_spfli
WHERE carrid = t_spfli-carrid
AND connid = t_spfli-connid.
LOOP AT t_flight INTO fs_flight.
WRITE: / fs_flight-carrid,
fs_flight-connid,
fs_flight-fldate.
ENDLOOP.
Regards
Abhijeet
‎2008 Aug 25 10:04 AM
‎2008 Aug 25 10:05 AM
Hi,
Please Import , Export parameters for your requirement.
regards
Jana
‎2008 Aug 25 10:06 AM
hi arun
use SUBMIT Statement
SUBMIT report2
WITH ITAB IN ITAB
AND RETURN.
Regards
Deva
‎2008 Aug 25 10:08 AM
Hi,
" In program ZAR1
EXPORT itab FROM itab TO MEMORY ID 'ZABC'.
" In program ZAR2
IMPORT itab TO itab FROM MEMORY ID 'ZABC'.
"Note:name and structure of the both internal table be same.Regards
Adil
‎2008 Aug 25 10:12 AM
If both are executable and you want to pass the data at runtime, then you can go for submit command. If both the programs are include programs and you are calling them from within the same program, then declare the internal table in the main program. The data will be available across the two program ZAR1 and ZAR2.
‎2008 Aug 25 10:22 AM
Hi,
You can use SAP memory or ABAP memory
Refer the link:
http://www.sap-img.com/abap/difference-between-sap-and-abap-memory.htm
http://help.sap.com/saphelp_nw70/helpdata/en/9f/db9df735c111d1829f0000e829fbfe/content.htm
Hope it will help you.
Regards
Natasha Garg
‎2008 Aug 25 10:23 AM
Hi,
plz take help of below code:
DATA: ITAB TYPE I OCCURS 10,
NUM TYPE I.
SUBMIT REP2 AND RETURN.
IMPORT ITAB FROM MEMORY ID 'HK'.
LOOP AT ITAB INTO NUM.
WRITE / NUM.
ENDLOOP.
TOP-OF-PAGE.
WRITE 'Report 1'.
ULINE.This program calls the following executable program (report):
REPORT REP2 NO STANDARD PAGE HEADING.
DATA: NUMBER TYPE I,
ITAB TYPE I OCCURS 10.
SET PF-STATUS 'MYBACK'.
DO 5 TIMES.
NUMBER = SY-INDEX.
APPEND NUMBER TO ITAB.
WRITE / NUMBER.
ENDDO.
TOP-OF-PAGE.
WRITE 'Report 2'.
ULINE.
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN 'MBCK'.
EXPORT ITAB TO MEMORY ID 'HK'.
LEAVE.
ENDCASE.hope this helps.
thanx,
dhanashri.