Monday 17 April 2017

Using Memory ID To Transfer Value

With the help of MEMORY ID we can transfer the value from one report to another. Following is a simple example to show how this works:

Source System:
*&---------------------------------------------------------------------*
*& Report  ZSOURCE
*&
*&---------------------------------------------------------------------*
*&
*& SOURCE SYSTEM: LISTING THE PLANT AGAINST A PARTICULAR EBELN
*&---------------------------------------------------------------------*

REPORT zsource.
TABLES: ekko, ekpo.

SELECT-OPTIONS: s_ebeln FOR ekko-ebeln.

START-OF-SELECTION.
  DATA: lt_ekko TYPE TABLE OF ekko,
        lt_res TYPE TABLE OF ekpo,
        ls_res TYPE ekpo
        .
  CLEAR: ls_res.
  REFRESH: lt_ekko, lt_res.
  FREE MEMORY ID 'TEMP'.

  SUBMIT zdest WITH s_ebeln IN s_ebeln AND RETURN.

  IMPORT lt_ekpo TO lt_res FROM MEMORY ID 'TEMP'.

  LOOP AT lt_res INTO ls_res.
    AT NEW ebeln.
      FORMAT INTENSIFIED ON.
      WRITE: / 'Plant: ',ls_res-ebeln.
      FORMAT INTENSIFIED OFF.
    ENDAT.

    WRITE: / ls_res-werks.
  ENDLOOP.

Destination System:
*&---------------------------------------------------------------------*
*& Report  ZDEST
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT zdest.
TABLES: ekko, ekpo.

SELECTION-SCREEN: BEGIN OF BLOCK b1.
SELECT-OPTIONS: s_ebeln FOR ekko-ebeln.
SELECTION-SCREEN: END OF BLOCK b1.

START-OF-SELECTION.

  DATA: lt_ekpo TYPE TABLE OF ekpo.

  SELECT *
  FROM ekpo
  INTO TABLE lt_ekpo
  WHERE ebeln IN s_ebeln.

  EXPORT lt_ekpo TO MEMORY ID 'TEMP'.

No comments:

Post a Comment

Report to find CDS view of Standard Table

A small change has been made to the original program ( SAP YARD Article ) so that it can also display the common CDS used by multiple table...