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 statement with variant

former_member515329
Participant
0 Kudos

Hi All,

I am using program RSUSR002 - here i have 4 variants - i want to execute all the 4 variants one by one using SUBMIT statement.and i want to download the list into spreadsheet (using menu options ->list->Export->spreadsheet).

Is it possible to automate this program with 4 variant and to download all 4 output(spreadsheets) in desktop without manual intervention?

Thanks in advance.

9 REPLIES 9

raymond_giuseppi
Active Contributor

Depending on your version, set the hidden parameter listmark in your submit statement, then import data from memory id 'USERLIST' or use class to get ALV data back in caller report.

0 Kudos

Hello Raymond - can you please elaborate more on this.

my sap Version - SAP NETWEAVER 7.5

thanks in advance

0 Kudos
The general way to retrieve ALV data has been discussed 100 times in the forum: please search CL_SALV_BS_RUNTIME_INFO

iftah_peretz
Active Contributor
0 Kudos

Hi,

There are many ways of going at it.

I'll illustrate just one (not sure it's the optimal one for you - not much information in your question):

You'll need to use the variant option in the SUBMIT command. Then you'll need to have the list exported to memory (you can Google examples, like this one). And, as suggested in the last link I provided, you can go over the list and export it to excel (many options, like abap2xlsx).

0 Kudos

Thanks Iftah for the reply..In below code i am able to get the list in list_tab..but the format is somewhat different..so how can i download this list_tab to excel and store it in the desktop.

SUBMIT RSUSR002 USING SELECTION-SET p_var1
                EXPORTING LIST TO MEMORY
                AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
  TABLES
    listobject = list_tab
  EXCEPTIONS
    not_found  = 1
    OTHERS     = 2.

0 Kudos

You loop over the result and adapt it to your needs, have it in any format that you want.

0 Kudos

Using SPLIT command will do the job.

Here is a draft of the code (I assume your it_list_asci table has a column named data and that the excel has 3 columns) - I am not in front of an SAP system, so I can't check it and I couldn't see in the documentation if it clears the values or not (in case of no match), if it doesn't use option 1 otherwise option 2.

"Option 1
DATA: column1 TYPE string,
      column2 TYPE string,
      column3 TYPE string.
LOOP AT it_list_asci INTO DATA(excel_row).
  CLEAR: column1,column2,column3. 
  SPLIT excel_row-data AT '|' INTO column1 column2 column3. 
"coulumn1-3 contains what you need
"... Your logic... 
ENDLOOP.
"Option 2
LOOP AT it_list_asci INTO DATA(excel_row).
  SPLIT excel_row-data AT '|' INTO: DATA(column1) DATA(column2) 
  DATA(column3). 
"coulumn1-3 contains what you need
"... Your logic...
ENDLOOP.

0 Kudos

I have declared a new internal table with 11 fields(11 columns) - but still data is not coming in column wise separator in excel, it is coming as combined data in only 1 column.

LOOP AT it_list_asci INTO wa_list_asci."DATA(excel_row).
   CLEAR : wa_excel_format.
   shift wa_list_asci-line.
  SPLIT wa_list_asci-line AT '|' INTO wa_excel_format-line1
                                      wa_excel_format-line2
                                      wa_excel_format-line3
                                      wa_excel_format-line4
                                      wa_excel_format-line5
                                      wa_excel_format-line6
                                      wa_excel_format-line7
                                      wa_excel_format-line8
                                      wa_excel_format-line9
                                      wa_excel_format-line10
                                      wa_excel_format-line11.
  APPEND wa_excel_format TO it_excel_format.
  CLEAR : wa_list_asci.
ENDLOOP.

  CALL FUNCTION 'GUI_DOWNLOAD'
     EXPORTING
       filename             = gv_fullpath
       filetype             = 'ASC'
     TABLES
       data_tab              = it_excel_format[]   "it_list_asci[]        
       fieldnames            = git_fieldnames[]  
     EXCEPTIONS
       file_open_error       = 1                         "#EC ARGCHECKED
       file_write_error      = 2
       OTHERS                = 3.

0 Kudos

I misunderstood you. You are in the phase were you want to take the output of the alv and export it to an excel and have it in a certain way, you are not using what I recommended, please search how to create excel from internal table, there's a lot of data there - I have already supplied you with links for that.