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: 

Use of SUBMIT to retrive data from std SAP program

Former Member
0 Kudos

Hi .

We have 1 SAP std program and 1 Z program for asset allocation.We need to combine these report.I need the data of SAP report in Z report. These is one table ITAB_DATA in SAP report which contains all data for display ALV.I want this data in my Z program.

I have written the following code.

submit RAGITT_ALV01 via selection-screen

USING SELECTION-SET 'TEST17247'

exporting list to memory

and return.

if sy-subrc = 0.

CALL FUNCTION 'LIST_FROM_MEMORY'

TABLES

LISTOBJECT = t_listobject

EXCEPTIONS

NOT_FOUND = 1

OTHERS = 2

I also tried

FM CALL FUNCTION 'SAVE_LIST'

FM CALL FUNCTION 'WRITE_LIST'

But these all FM contains data in different format.

Can anyone suggest

6 REPLIES 6

Former Member
0 Kudos

Hi,

The approach you are following is right.

We have used it the same way:

  • Print report

call function 'LIST_FROM_MEMORY'

tables

listobject = itab_abaplist

exceptions

not_found = 1

others = 2.

if sy-subrc eq 0.

call function 'WRITE_LIST'

tables

listobject = itab_abaplist

exceptions

empty_list = 1

others = 2.

endif.

After this call FM LIST_TO_ASCI to convert to ASCI format.

here itab_abaplist is declared like

data:itab_abaplist like abaplist occurs 0 with header line.

Rgds,

HR

Former Member
0 Kudos
FU SAVE_LIST
____________________________________________________
Text
Save list

Saving a list
The specified list is returned to the contain LISTOBJECT.  You can then process the container like any other internal table (for example, using EXPORT to export it to the database or to memory).

<b>SAVE_LIST is noto suitable for saving lists produced during background processing.</b>

and what u can do is U have to convert LIST data to PDF or any otherforamts and Save on PC/Apps Server.

CONVERT_OTF or CONVERT_*

regards

Prabhu

Former Member
0 Kudos

Hi,

Please pass ur mail id ,

i have a sample code upon ur requirement , i will pass it to u ,

this will help u understand how to retrieve the data from another alv report to ur calling program ..

Regards,

Vijay.

0 Kudos

Hi Vijay,

i have the same problem, i'm trying to retrieve the data from alv report to a calling program (function module, it's to extract alv data to BW) but i don't know how to set parameters in submit using selection-sets.

can you send me a sample code?

thanks in advance

Message was edited by:

Juan Antonio Del Rincó

Former Member
0 Kudos

hi,

SUBMIT zreport EXPORTING LIST TO MEMORY.

CALL FUNCTION 'LIST_FROM_MEMORY'

TABLES

listobject = t_listobject

EXCEPTIONS

not_found = 4

OTHERS = 8.

<b>CALL FUNCTION 'LIST_TO_ASCI'</b>

EXPORTING

list_index = -1

TABLES

listasci = vlist

listobject = t_listobject

EXCEPTIONS

empty_list = 1

list_index_invalid = 2

OTHERS = 3.

IF sy-subrc NE '0'.

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

ENDIF.

After the FM <b>'LIST_FROM_MEMORY'</b>, you need to use FM <b>'LIST_TO_ASCI'</b> to convert to original Format ..

Regards

Sudheer

Former Member
0 Kudos

hi did nt look back at this thread sorry..

i n case u have want to have idea

just excute the code ..

take a program a.

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.

now take one more program as b .

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.

u can get the data in to ur calling program ..

regards,

VIJay