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

Submit Statement

Former Member
0 Likes
2,371

Hi All,

I've 2 programs say PR1 & PR2. I have to select output row/rows of program PR1 as Input for PR2 (at click event). I tried the submit statement for it as below.

In Report PR1:

SUBMIT PR2

WITH SELECTION-TABLE itab

AND RETURN .

Here itab is the internal table which contains the selected records from PR1 output.

I tried this with Import & Export Statement also but not getting the desired output.

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,456

You can pass values to program2 using the selection table or using the WITH extenstion.

submit report2
       WITH P_PARM1 = 'AValue'
             and return.

Here P_PARM1 is a parameter in the REPORT2.

What part are you having a problem with? Can you post your code?

Regards

Rich Heilman

9 REPLIES 9
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,457

You can pass values to program2 using the selection table or using the WITH extenstion.

submit report2
       WITH P_PARM1 = 'AValue'
             and return.

Here P_PARM1 is a parameter in the REPORT2.

What part are you having a problem with? Can you post your code?

Regards

Rich Heilman

Read only

Former Member
0 Likes
1,456

Hi Bhavana,

There should not be any problem with Imprt and Export.

Export int_tab to memory id 'MID'.

Then you call submit statement

SUBMIT prg_name and return.

From the other program , you can IMPORT the table using IMPORT Statement

Regards,

SP.

Read only

Former Member
0 Likes
1,456

the selection-table is not the output of the pr2 program but an internal table which has all the selection criteria(all parameters,select-option values) in PR2 program.

Itab must be filled with all those selection values before you pass to the submit statement.

Regards,

ravi

Read only

Former Member
0 Likes
1,456

HI,

Yopu need to save the Data to the Database, fo rthis you need to use Import and Export with Database

<b>For Export :</b>

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3c2c358411d1829f0000e829fbfe/content.htm

<b>for Import:</b>

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3c46358411d1829f0000e829fbfe/content.htm

after this you need to Delete the data from the Database

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3c46358411d1829f0000e829fbfe/content.htm

Use the Submit statment with the use of this Internal table

********************************************************

if you want the output of a report as input

http://www.sapdevelopment.co.uk/reporting/rep_submit.htm

Thanks

Sudheer

Read only

Former Member
0 Likes
1,456

Hi Bhavana,

Consider these two programs I have done using both <b>WITH SELECTION-TABLE</b> and <b>IMPORT/EXPORT</b>.

In Program 1(ZZTEST_ARUN_1).

I have two radio buttons. If I select Material the program executes its own code. If I select plant data is fetched and exported to memory. Then it gets the selection parameters of the Program 2(ZZTEST_ARUN_2) through the FM <b>RS_REFRESH_FROM_SELECTOPTIONS</b>. Then I populate the values for selection screen and pass using the

<b>SUBMIT....WITH SELECTION-TABLE</b> option.


REPORT zztest_arun_1.
  TABLES: t001w.
  DATA : it_marc TYPE STANDARD TABLE OF marc WITH HEADER LINE,
         it_werks TYPE STANDARD TABLE OF t001w WITH HEADER LINE.

   PARAMETERS material RADIOBUTTON  GROUP  abc.     "Material General Details

   PARAMETERS plant RADIOBUTTON GROUP abc DEFAULT 'X'.      "Material Plant Details

   START-OF-SELECTION.

   IF material EQ 'X'.
   
*If Material selected own code executes   

    SELECT * FROM marc INTO TABLE it_marc UP TO 200 ROWS .
     LOOP AT it_marc.

     WRITE :/ it_marc-matnr,
            it_marc-werks.
     ENDLOOP.

   ENDIF.

  IF plant EQ 'X'.

*If Plant selected data fetched   

    SELECT * FROM t001w INTO TABLE it_werks UP TO 50 ROWS.
    
*Exported to Memory
    
    EXPORT it_werks[] TO MEMORY ID 'TEST'.

*Declare on selection table type RSPARAMS

<b>    DATA :   stable	LIKE	rsparams OCCURS 0 WITH HEADER LINE.</b>

*Call this FM to get the Selection screen details
*of Program ZZTEST_ARUN_2 (it returns Select Options, Parameters..)

  <b>  CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'</b>
       EXPORTING
         curr_report     = 'ZZTEST_ARUN_2'
      TABLES
         selection_table = stable
      EXCEPTIONS
         not_found       = 1
         no_report       = 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.

   stable-sign = 'I'.
   stable-option = 'BT'.
   
* populate some selection condition
   READ TABLE it_werks INDEX 10.
   stable-low = it_werks-werks.

   READ TABLE it_werks INDEX 40.
   stable-high = it_werks-werks.

   APPEND stable.

*Submit it then
   SUBMIT zztest_arun_2
       WITH SELECTION-TABLE stable
       AND RETURN.

   ENDIF.


Second Program.


REPORT zztest_arun_2.
TABLES: t001w.

DATA : it_werks TYPE STANDARD TABLE OF t001w WITH HEADER LINE.

SELECT-OPTIONS : s_werks FOR t001w-werks.



*Import the stored data.
IMPORT it_werks[] FROM MEMORY ID 'TEST'.


*Display the data based on selection criteria got
*form ZZTEST_ARUN_1
LOOP AT it_werks WHERE werks <b> IN s_werks</b>.
  WRITE : / it_werks-werks,
            it_werks-name1.

ENDLOOP.

Regards,

Arun Sambargi.

Message was edited by: Arun Sambargi

Read only

former_member183804
Active Contributor
0 Likes
1,456

Hello Bhavana,

the selection table can only succeed if the select-options of the 2nd report fit to the output of the first report. But even if you juggle out the correct format this is very unstable as there are no means for static checks on this relationship.

As you mentioned already import/export are another possibilty, but this lacks also.

Using Reports as modularization unit is in general not the best idea. My proposal is to move all logic of the 2nd report into a method / fuba and call from the 1st report. If you also need the 2nd report you can easily also call the fuba from there.

Best Regards

Klaus

Read only

Former Member
0 Likes
1,456

Hi All,

I’m populating the data in the selection table “stable” as below.

CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'

EXPORTING

curr_report = ‘ZINFO'

TABLES

selection_table = stable

EXCEPTIONS

not_found = 1

no_report = 2

OTHERS = 3.

LOOP AT itab1.

READ TABLE stable WITH KEY selname = 'WEKES'.

IF sy-subrc = 0.

stable-sign = 'I'.

stable-option = 'EQ'.

stable-low = itab1-wekrs.

MODIFY stable TRANSPORTING sign option low

WHERE selname = 'P_AUFNR'.

ENDIF

READ TABLE stable WITH KEY selname = 'TANKID'.

IF sy-subrc = 0.

stable-sign = 'I'.

stable-option = 'EQ'.

stable-low = itab1-tankid.

MODIFY stable TRANSPORTING sign option low

WHERE selname = 'TANKID'.

ENDIF.

SUBMIT ZINFO

WITH SELECTION-TABLE stable

AND RETURN .

ENDLOOP.

In this case I can populate the selection screen fields of Zinfo by only last selected record from output.

I want populate the selection screen of prg “Zinfo” by multiple records (Multiple selections) selected from output of calling program.

How can I populate the stable for multiple records? Which value of option field I need to use for it?

Thanks,

Bhavana

Read only

Former Member
0 Likes
1,456

HI Bhavana,

Do it in this way.


REPORT  zztest_1.

DATA :   stable	LIKE	rsparams OCCURS 0 WITH HEADER LINE,
         it_mara TYPE STANDARD TABLE OF mara WITH HEADER LINE.

START-OF-SELECTION.

  SELECT * FROM mara INTO TABLE it_mara UP TO 10 ROWS.
  CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
    EXPORTING
      curr_report     = 'ZZTEST_2'
    TABLES
      selection_table = stable
    EXCEPTIONS
      not_found       = 1
      no_report       = 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.

  BREAK-POINT.

*Read the selection table.

  READ TABLE stable WITH KEY selname = 'MATNR'.
  IF sy-subrc = 0.

*Then loop the output table and appen the values.
    LOOP AT it_mara.  "Specify some condition if possible to restrict the values.

      stable-sign   = 'I'.
      stable-option = 'EQ'.
      stable-low    =  it_mara-matnr.
      <b>APPEND stable.</b>
    ENDLOOP.
  ENDIF.

  BREAK-POINT.

*Then submit the Program

  SUBMIT zztest_2
  WITH SELECTION-TABLE stable
  AND RETURN .


Regards,

Arun Sambargi.

Read only

Former Member
0 Likes
1,456

Hai Bhavana

SUBMIT rep.

Additions

1. ... LINE-SIZE col

2. ... LINE-COUNT lin

3. ... TO SAP-SPOOL

4. ... VIA SELECTION-SCREEN

5. ... AND RETURN

6. ... EXPORTING LIST TO MEMORY

7. ... USER user VIA JOB job NUMBER n

8. ... Various additions for parameter transfer to rep

9. ... USING SELECTION-SETS OF PROGRAM prog

Effect

Calls the report rep . Leaves the active program and starts the new report rep .

Addition 1

... LINE-SIZE col

Effect

Prints the report with the line width col .

Addition 2

... LINE-COUNT lin

Effect

Prints the report with lin lines (per page).

Addition 4

... VIA SELECTION-SCREEN

Effect

Displays the selection screen for the user. In this case, the selection screen is redisplayed after return from the report list display - the user's entries are retained.

Addition 5

... AND RETURN

Effect

Returns to the calling transaction or program after the called program has been executed. SUBMIT ... AND RETURN creates a new internal mode .

Addition 6

... EXPORTING LIST TO MEMORY

Effect

Does not display the output list of the called report, but saves it in SAP memory and leaves the called report immediately. Since the calling program can read the list from memory and process it further, you need to use the addition ... AND RETURN . Also, since the called report cannot be requested for printing, the addition ... TO SAP-SPOOL is not allowed here. You can read the saved list from SAP memory with the function module 'LIST_FROM_MEMORY' and then (for example) store it in the database with EXPORT . You can process this list further with the function modules 'WRITE_LIST' , 'DISPLAY_LIST' ... of the function group "SLST" .

Addition 7

... USER user VIA JOB job NUMBER n

Effect

Schedules the specified report in the job specified by the job name job and the job number n . The job runs under the user name user and you can omit the addition USER user . The assignment of the job number occurs via the function module JOB_OPEN (see also the documentation for the function modules JOB_CLOSE and JOB_SUBMIT . This addition can only be used with the addition ...AND RETURN .

Note

When scheduling a report with the SUBMIT ... VIA JOB job NUMBER n statement, you should always use the addition ...TO SAP-SPOOL to pass print and/or archive parameters. Otherwise, default values are used to generate the list and this disturbs operations in a production environment.

Addition 9

... USING SELECTION-SETS OF PROGRAM prog

Effect

Uses variants of the program prog when executing the program rep .

Note

Important

The programs prog and rep must have the same SELECT-OPTIONS and PARAMETER s. Otherwise, variants of the program prog may be destroyed.

Note

When using this addition, the specified variant vari of the program prog is taken in USING SELECTION-SET vari . On the other hand, all variant-related actions on the selection screen of rep (Get , Save as variant , Display , Delete ) refer to the variants of prog .

Example

SUBMIT REPORT01

VIA SELECTION-SCREEN

USING SELECTION-SET 'VARIANT1'

USING SELECTION-SETS OF PROGRAM 'REPORT00'

AND RETURN.

Effect

Executes the program REPORT01 with the variant VARIANT1 of the program REPORT00 .

Note

Runtime errors

LOAD_PROGRAM_NOT_FOUND : The specified program was not found.

SUBMIT_WRONG_TYPE : The specified program is not a report.

SUBMIT_IMPORT_ONLY_PARAMETER : Only one value passed to a report parameter.

SUBMIT_WRONG_SIGN : Invalid value passed to a selection with the addition SIGN .

SUBMIT_IN_ITAB_ILL_STRUCTURE : Table passed to a selection with WITH sel IN itab had an unexpected structure.

Try with this Example

Data: listobject like abaplist occurs 1 with header line.

CALL FUNCTION 'LIST_FROM_MEMORY'

TABLES

listobject = listobject

EXCEPTIONS

OTHERS = 1 .

IF sy-subrc <> 0.

message ID '61' TYPE 'E' NUMBER '731'

with 'LIST_FROM_MEMORY'.

ENDIF.

Regards

Sreeni