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

EXPORTING LIST TO MEMORY

Former Member
0 Likes
2,090

- I want to call another program (prgB) from within a program (prgA).

- Export the results from prgB to memory

- Import these results to prgA, do my processing and,

- Then Free the memory

I am using the below code but my itab_list is not populating. It simply contains all zeroes despite the fact that the calling program has succesfully worked.

SUBMIT rplabsg0_sxp_oxp_hist

WITH pnpbegda = cal_start_date

WITH pnpendda = cal_end_date

WITH pnppernr-low = pernr-pernr

WITH s_type IN it_type

EXPORTING LIST TO MEMORY AND RETURN.

*

CALL FUNCTION 'LIST_FROM_MEMORY'

TABLES

LISTOBJECT = itab_list

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.

ENDIF.

CALL FUNCTION 'LIST_TO_ASCI'

EXPORTING

list_index = -1

TABLES

listasci = list

listobject = itab_list

EXCEPTIONS

empty_list = 1

list_index_invalid = 2

OTHERS = 3.

IF sy-subrc NE '0'.

WRITE:/ 'LIST_TO_ASCI error !! ', sy-subrc.

ENDIF.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,438

*CALL FUNCTION 'LIST_FROM_MEMORY'

*TABLES

*LISTOBJECT = itab_list

*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.

*ENDIF.

just write this.

-


IMPORT listobject FROM MEMORY ID '%_LIST'.

IF SY-SUBRC <> 0.

RAISE NOT_FOUND.

ENDIF.

CALL FUNCTION 'LIST_TO_ASCI'

****EXPORTING "comment here

****list_index = -1 "comment here

TABLES

listasci = <b>ITAB_LIST</b> "look out here

listobject = <b>listobject</b> "look out here

EXCEPTIONS

empty_list = 1

list_index_invalid = 2

OTHERS = 3.

IF sy-subrc NE '0'.

WRITE:/ 'LIST_TO_ASCI error !! ', sy-subrc.

ENDIF.

,,

just check this out and let me know ..

by the way put a break point on itab_list and see if this is getting populated.

regards,

Vijay.

Message was edited by: Vijay

*CALL FUNCTION 'LIST_FROM_MEMORY'

*TABLES

*LISTOBJECT = itab_list

*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.

*ENDIF.

just write this.

-


IMPORT listobject FROM MEMORY ID '%_LIST'.

IF SY-SUBRC <> 0.

RAISE NOT_FOUND.

ENDIF.

CALL FUNCTION 'LIST_TO_ASCI'

****EXPORTING "comment here

****list_index = -1 "comment here

TABLES

listasci = <b>ITAB_LIST</b> "look out here

listobject = <b>listobject</b> "look out here

EXCEPTIONS

empty_list = 1

list_index_invalid = 2

OTHERS = 3.

IF sy-subrc NE '0'.

WRITE:/ 'LIST_TO_ASCI error !! ', sy-subrc.

ENDIF.

,,

just check this out and let me know ..

by the way put a break point on itab_list and see if this is getting populated.

regards,

Vijay.

Message was edited by: Vijay

6 REPLIES 6
Read only

Former Member
0 Likes
1,439

*CALL FUNCTION 'LIST_FROM_MEMORY'

*TABLES

*LISTOBJECT = itab_list

*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.

*ENDIF.

just write this.

-


IMPORT listobject FROM MEMORY ID '%_LIST'.

IF SY-SUBRC <> 0.

RAISE NOT_FOUND.

ENDIF.

CALL FUNCTION 'LIST_TO_ASCI'

****EXPORTING "comment here

****list_index = -1 "comment here

TABLES

listasci = <b>ITAB_LIST</b> "look out here

listobject = <b>listobject</b> "look out here

EXCEPTIONS

empty_list = 1

list_index_invalid = 2

OTHERS = 3.

IF sy-subrc NE '0'.

WRITE:/ 'LIST_TO_ASCI error !! ', sy-subrc.

ENDIF.

,,

just check this out and let me know ..

by the way put a break point on itab_list and see if this is getting populated.

regards,

Vijay.

Message was edited by: Vijay

Read only

Former Member
0 Likes
1,438

Hi,

Run the program with the same selection parameters that you are passing through the program and see if generates a list indeed.

REgards,

Ravi

Read only

Former Member
0 Likes
1,438

The calling program is producing a list fine. The trouble is that it produces an ALV list, which means the user has to back out of the program (prgB) to return processing to (prgA). I have tried using the 'export to memory ID', 'import from memory Id', but like I said this still produces prgs B ALV list.

What I want to do is similiar to using the spool parameters capture prgBs results (without the need for the ALV grid) and thus retunr to prgA without user interaction. Accordfing to SAP help the 'Submit... EXPORTING LIST TO MEMORY' should not display the ALV output list, but when I use the above code it does???

Read only

Former Member
0 Likes
1,438

Hi ,

u mean to say that the called program is producing an ALV o/p

and u need to fetch the data from that ..

just create two abap programs in ur dev server like this ..

im giving u two programs .. just execute the same ..

see the second program gives u an o/p in alv list ..

now im reading the content from alv o/p list to my program in a

this is the process..

first program.

-


REPORT zex8 NO STANDARD PAGE HEADING .

TABLES : marc.

PARAMETER : p_matnr LIKE marc-matnr.

DATA : v1_werks LIKE marc-werks,

v2_werks LIKE marc-werks.

DATA : in TYPE i.

data : begin of itab occurs 0,

text(256),

end of itab.

DATA : BEGIN OF it_marc OCCURS 0,

matnr LIKE marc-matnr,

werks LIKE marc-werks,

END OF it_marc.

DATA : BEGIN OF jtab OCCURS 0,

matnr LIKE marc-matnr,

werks LIKE marc-werks,

lgort like mard-lgort,

END OF jtab.

DATA : listobject LIKE abaplist OCCURS 0 WITH HEADER LINE.

START-OF-SELECTION.

SELECT matnr werks

FROM marc

INTO TABLE it_marc

WHERE matnr EQ p_matnr.

IF NOT it_marc[] IS INITIAL.

SORT it_marc BY werks.

READ TABLE it_marc INDEX 1.

v1_werks = it_marc-werks.

in = sy-dbcnt.

READ TABLE it_marc INDEX in.

v2_werks = it_marc-werks.

SUBMIT zex9

WITH p_matnr EQ p_matnr

WITH s_werks BETWEEN v1_werks AND v2_werks

EXPORTING LIST TO MEMORY

AND RETURN.

IMPORT listobject FROM MEMORY ID '%_LIST'.

IF SY-SUBRC <> 0.

RAISE NOT_FOUND.

ENDIF.

CALL FUNCTION 'LIST_TO_ASCI'

  • EXPORTING

  • LIST_INDEX = -1

  • WITH_LINE_BREAK = ' '

TABLES

listasci = itab

LISTOBJECT = 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.

ENDIF.

DATA : J TYPE I VALUE 0 ,

K TYPE I.

loop at itab.

J = J + 1.

IF J > 3 AND ITAB-TEXT NA '----


'.

jtab-matnr = itab-text+1(18).

jtab-werks = itab-text+20(4).

jtab-lgort = itab-text+25(4).

append jtab.

clear jtab.

ENDIF.

endloop.

loop at jtab.

write : / jtab-lgort.

endloop. .

.

  • CALL FUNCTION 'WRITE_LIST'

  • EXPORTING

  • write_only = 'X'

  • TABLES

  • listobject = listobject

  • EXCEPTIONS

  • empty_list = 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.

  • ENDIF.

IF NOT LISTOBJECT IS INITIAL.

CLEAR LISTOBJECT.

ENDIF.

-


second program this produces an alv list okay ..

REPORT zex9 NO STANDARD PAGE HEADING.

TYPE-POOLS : slis.

TABLES : marc,

mard ,

makt.

PARAMETERS : p_matnr LIKE marc-matnr.

SELECT-OPTIONS :s_werks FOR marc-werks.

DATA : BEGIN OF it_mard OCCURS 0,

matnr LIKE mard-matnr,

werks LIKE mard-werks,

lgort LIKE mard-lgort,

END OF it_mard.

DATA : fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE ,

gd_repid LIKE sy-repid.

SELECT matnr werks lgort

FROM mard

INTO TABLE it_mard

WHERE werks IN s_werks

AND matnr EQ p_matnr.

fieldcatalog-col_pos = 1.

fieldcatalog-fieldname = 'MATNR'.

fieldcatalog-seltext_m = 'MATERIAL NUMBER'.

fieldcatalog-outputlen = 18.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-col_pos = 2.

fieldcatalog-fieldname = 'WERKS'.

fieldcatalog-seltext_m = 'WERKS'.

fieldcatalog-outputlen = 4.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-col_pos = 3.

fieldcatalog-fieldname = 'LGORT'.

fieldcatalog-seltext_m = 'STORLOC'.

fieldcatalog-outputlen = 4.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

gd_repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

i_callback_program = gd_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_STRUCTURE_NAME =

  • IS_LAYOUT =

it_fieldcat = fieldcatalog[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = it_mard

EXCEPTIONS

program_error = 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.

ENDIF.

-


Read only

Former Member
0 Likes
1,438

Thanks that helped a lot. The problem I had was the program that I was calling was using 'REUSE_ALV_GRID_DISPLAY' to produce the results, whcih doesn't appear in SAP memory. I cahnged it to use 'REUSE_ALV_LIST_DISPLAY' and I was able to import the results to my program...Thanks again.

Read only

Former Member
0 Likes
1,438

The thing is u need calculate the number of spaces that the TOP-OF-PAGE is taking when u use ALV grid Format ..

and then skip the lines and hold ur data ..

itab content is there mate ..

only thing is u need to get it ..by skipping that top of page portion ..

try doing this in debugging ..

glad that u got the edge ..

regards,

VIjay