Application Development 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: 

SUBMIT rep EXPORTING LIST TO MEMORY newbie question

Former Member
0 Kudos

Hi,

i am sorry for this stupid question, now I am learning abap.

I need to submit some report from function module and recieve from that report some table.

So I think that I have to submit this way:

SUBMIT rep EXPORTING LIST TO MEMORY.

now i am not sure how to handle that table which i would like to return from report. I read that i should use

function REUSE_ALV_LIST_DISPLAY? is it true??

So i tried it and now i dont know how to handle that list from report.

In function LIST_FROM_MEMORY i can read it, but only LIKE ABAPLIST:

DATA LISTTAB LIKE ABAPLIST

OCCURS 0 WITH HEADER LINE.

CALL FUNCTION 'LIST_FROM_MEMORY'

TABLES

listobject = LISTTAB

How can i now gat back that table which i wrote in report in same structure? is it possible or i have to use LIST_TO_ASCI and parse strings?

i hope that it is clear(but i dont know:)

thanks for any answer

JJ

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Here is a complete example.

The Called Program.....(try running this first to view the output)

<b>REPORT ztest.

DO 10 TIMES.

WRITE : / sy-index.

ENDDO.</b>

The Calling Program.....

<b>REPORT ztest2 LINE-SIZE 255.

SUBMIT ztest EXPORTING LIST TO MEMORY AND RETURN.

DATA : listtable LIKE abaplist OCCURS 0.

CALL FUNCTION 'LIST_FROM_MEMORY'

TABLES

listobject = listtable

EXCEPTIONS

not_found = 1

OTHERS = 2.

CALL FUNCTION 'WRITE_LIST'

TABLES

listobject = listtable.</b>

Cheers!

Rishi

10 REPLIES 10

andreas_mann3
Active Contributor
0 Kudos

Hi ,

alternative: export / import to memory

(look at abap-help)

example:

*fm
  SUBMIT ZZZZ001  WITH p1   = 'X'
                  WITH p2   = 'Y' AND RETURN.

*in ZZZZ001
  export itab to MEMORY ID 'M1'.
*
*in fm
  IMPORT itab  FROM MEMORY ID 'M1'.

Andreas

0 Kudos

Hi,

step 1.

SUBMIT report.

step 2:

DATA : listtable LIKE abaplist OCCURS 0.

CALL FUNCTION 'LIST_FROM_MEMORY'

TABLES

listobject = listtable

EXCEPTIONS

not_found = 1

OTHERS = 2.

Step 3.

DATA : it_text LIKE solisti1 OCCURS 0 WITH HEADER LINE.

CALL FUNCTION 'LIST_TO_ASCI'

TABLES

listasci = it_text

listobject = listtab.

Loop at it_text.

PARSE the strings int to final table , pass it to ALV display

Regds,

Manohar

0 Kudos

I tried this, but table from memory is empty(I am almost sure that when i store it into memory it contains some data).

Where may be a problem?

JJ

0 Kudos

SUBMIT rmmvrz00

WITH ms_matnr IN ms_matnr "Material

WITH ms_werks IN ms_werks "Plant

WITH mtart IN mtart "Material Type

EXPORTING LIST TO MEMORY

AND RETURN.

For your reference, check if you are passing all the required parameters .

Manohar

0 Kudos

I checked it, still the same problem. Imported table is empty .

Former Member
0 Kudos

Hello Jiri,

try the following:

Submit rep exporting list to memory AND RETURN.

After returning from the report, you can retrieve the list with function module LIST_FROM_MEMORY.

Hope this helps and you enjoy SDN,

regards, Kathrin!

Former Member
0 Kudos

Here is a complete example.

The Called Program.....(try running this first to view the output)

<b>REPORT ztest.

DO 10 TIMES.

WRITE : / sy-index.

ENDDO.</b>

The Calling Program.....

<b>REPORT ztest2 LINE-SIZE 255.

SUBMIT ztest EXPORTING LIST TO MEMORY AND RETURN.

DATA : listtable LIKE abaplist OCCURS 0.

CALL FUNCTION 'LIST_FROM_MEMORY'

TABLES

listobject = listtable

EXCEPTIONS

not_found = 1

OTHERS = 2.

CALL FUNCTION 'WRITE_LIST'

TABLES

listobject = listtable.</b>

Cheers!

Rishi

0 Kudos

Here is an example. ZTESTAKS3 submits the program ZTESAKS1. This example shows both export internal table to memory and also list to memory.


REPORT ztestaks3 MESSAGE-ID zz.

DATA: v_matnr LIKE mara-matnr.

DATA: t_listobject TYPE abaplist OCCURS 0 WITH HEADER LINE.

DATA: t_mara TYPE mara OCCURS 0 WITH HEADER LINE.

DATA: BEGIN OF t_ascilist OCCURS 0,
        line(200).
DATA: END OF t_ascilist.

SELECT-OPTIONS: s_matnr FOR v_matnr.

*------------------
START-OF-SELECTION.
*------------------

  SUBMIT ztestaks1 WITH s_matnr IN s_matnr EXPORTING LIST TO MEMORY
  AND RETURN.
  CALL FUNCTION 'LIST_FROM_MEMORY'
       TABLES
            listobject = t_listobject
       EXCEPTIONS
            not_found  = 1
            OTHERS     = 2.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ELSE.
    CALL FUNCTION 'LIST_TO_ASCI'
*     EXPORTING
*       LIST_INDEX               = -1
*       WITH_LINE_BREAK          = ' '
      TABLES
        listasci                 = t_ascilist
        listobject               = t_listobject
      EXCEPTIONS
        empty_list               = 1
        list_index_invalid       = 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.
    ELSE.
      WRITE:/ 'Below are the lines from the submitted program.'.
      LOOP AT t_ascilist.
        WRITE:/ t_ascilist-line.
      ENDLOOP.
      SKIP 2.
    ENDIF.
  ENDIF.

  IMPORT t_mara FROM MEMORY ID 'T_MARA'.
  WRITE:/

'Here is the output from the table exported from the submitted program.'
  .
  LOOP AT t_mara.
    WRITE:/ t_mara-matnr.
  ENDLOOP.

Submitted program code:


REPORT ztestaks1 MESSAGE-ID zz.

DATA: v_matnr LIKE mara-matnr,
      v_maktx LIKE makt-maktx.

DATA: t_mara TYPE mara OCCURS 0 WITH HEADER LINE.

DATA: BEGIN OF t_makt OCCURS 0,
        matnr LIKE makt-matnr.
DATA: END OF t_makt.

SELECT-OPTIONS: s_matnr FOR v_matnr,
                s_maktx FOR v_maktx.


START-OF-SELECTION.

  SELECT matnr INTO TABLE t_makt
               FROM makt
              WHERE matnr IN s_matnr
                AND maktx IN s_maktx.

  SELECT * FROM mara
           INTO TABLE t_mara FOR ALL ENTRIES IN t_makt
          WHERE matnr = t_makt-matnr.

  EXPORT t_mara TO MEMORY ID 'T_MARA'.

  WRITE:/ 'This list is from the submitted program'.
  SKIP 1.
  LOOP AT t_mara.
    WRITE:/ t_mara-mtart.
  ENDLOOP.

<u><b>Points to note:</b></u>

1. When you export list to memory, you are exporting the entire output, including any page headers/footers and formatting characters like vertical lines or horizontal lines etc. This is not same as exporting just the internal table to memory.

2. When you export an internal table or a value to memory with an id, two things to remember is that the id name and the internal table name should be the same.

If you take care of these two aspects, you should be able to achieve what you wanted to achieve.

Please let me know if you need more clarification and if it solved your problem, please close the post.

Srinivas

0 Kudos

thanks for all answers, especcially for that two notes.

When i was trying export to memory version i didnt know that the same id is not enough to obtain table(i had different names).

JJ

0 Kudos

This message was moderated.