Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Internal table values

Former Member
0 Likes
1,051

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,012

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

8 REPLIES 8
Read only

Former Member
0 Likes
1,012

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

Read only

Former Member
0 Likes
1,012

use set/get parameter statements

Read only

Former Member
0 Likes
1,012

Hi,

Please Import , Export parameters for your requirement.

regards

Jana

Read only

Former Member
0 Likes
1,012

hi arun

use SUBMIT Statement

SUBMIT report2

WITH ITAB IN ITAB

AND RETURN.

Regards

Deva

Read only

Former Member
0 Likes
1,014

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

Read only

Former Member
0 Likes
1,012

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.

Read only

Former Member
0 Likes
1,012
Read only

Former Member
0 Likes
1,012

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.