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

PERFORM using tables

Former Member
0 Likes
35,422

Hi,

I want to pass different tables using single perform, whats the correct way?

Also want to pass one string parameter.

Thanks,

Amol

3 REPLIES 3
Read only

Former Member
0 Likes
11,672

Hi

see this doc

PERFORM - parameter_list

Syntax

... [TABLES itab1 itab2 ...]

[USING a1 a2 ...]

[CHANGING a1 a2 ...].

Extras:

1. ... TABLES itab1 itab2 ...

2. ... USING a1 a2 ...

3. ... CHANGING a1 a2 ...

Effect

These additions assign actual parameters to the formal parameters from the parameter interface for the subroutine subr. You can specify all data objects whose data type matches the typing of the corresponding formal parameter (see Check Typing) as actual parameters. Each formal parameter assumes all the properties of the actual parameter assigned to it when it is called.

Addition 1

... TABLES itab1 itab2 ...

Effect

If you specify the addition TABLES, each table parameter t1 t2 ... for the subroutine called that is defined with the addition TABLES to the FORM statement must be assigned an internal table itab as the actual parameter. The assignment of the actual parameters to the formal parameters takes place using their positions in the lists t1 t2 ... and itab1 itab2 ... .

You can only specify standard tables for itab. Transfer takes place by means of a reference. If a specified table itab has a header line, this is also transferred; otherwise, the header line in the corresponding table parameter t is blank when it is called.

Note

Use of table parameters in the interface for subroutines is obsolete but a large number of subroutines have not yet been converted to appropriately typed USING or CHANGING parameters, so that they must still be supplied with data by the TABLES addition to the PERFORM statement.

Example

Static call of the internal subroutine select_sflight transferring a table parameter.

PARAMETERS: p_carr TYPE sflight-carrid,

p_conn TYPE sflight-connid.

DATA sflight_tab TYPE STANDARD TABLE OF sflight.

...

PERFORM select_sflight TABLES sflight_tab

USING p_carr p_conn.

...

FORM select_sflight TABLES flight_tab LIKE sflight_tab

USING f_carr TYPE sflight-carrid

f_conn TYPE sflight-connid.

SELECT *

FROM sflight

INTO TABLE flight_tab

WHERE carrid = f_carr AND

connid = f_conn.

ENDFORM.

Addition 2

... USING a1 a2 ...

Addition 3

... CHANGING a1 a2 ...

Effect

If you specify the additions USING and CHANGING, an actual parameter a1 a2 ... of the appropriate type must be assigned to each of the formal parameters u1 u2 ... and c1 c2 ... defined with the same additions to the FORM statement. The actual parameters specified after USING and CHANGING form one shared list. They are assigned to the formal parameters after the position in the shared list. The type of parameter transfer is defined with the additions USING and CHANGING to the FORM statement. The addition USING must be before CHANGING. Otherwise, the assignment of the actual parameters to the additions USING and CHANGING is irrelevant to the PERFORM statement. It is also irrelevant whether only one or both of the additions is specified.

Notes

For the sake of program documentation, we advise that you specify the additions USING and CHANGING in the FORM statement according to the definition of the parameter interface.

In non-Unicode programs, you can address memory area outside an actual parameter if an actual parameter a1 a2 ... is assigned offset or length specifications. In non-Unicode programs, the length is set to the length of the current parameter if an offset is specified without a length. Both of these lead to warnings in the syntax check and to syntax errors in Unicode programs. The rules for the ASSIGN statement apply to the addressable memory area in non-Unicode programs as well.

Example

The following five PERFORM statements mean the same but only the fourth is recommended, since it is the only one that documents the interface of the subroutine called.

DATA: a1 TYPE string,

a2 TYPE string,

a3 TYPE string,

a4 TYPE string.

PERFORM test USING a1 a2 a3 a4.

PERFORM test CHANGING a1 a2 a3 a4.

PERFORM test USING a1 CHANGING a2 a3 a4.

PERFORM test USING a1 a2 CHANGING a3 a4.

PERFORM test USING a1 a2 a3 CHANGING a4.

...

FORM test USING p1 TYPE string

p2 TYPE string

CHANGING value(p3) TYPE string

value(p4) TYPE string.

...

ENDFORM.

<b>Reward points for useful Answers</b>

Regards

Anji

Read only

Former Member
0 Likes
11,672

Hi,

Try like this:

DATA: BEGIN OF line,

col1 TYPE i,

col2 TYPE i,

END OF line.

DATA itab LIKE STANDARD TABLE OF line.

data ch(1) type c.

PERFORM fill CHANGING itab.

PERFORM out USING itab.

&----


*& Form FILL

&----


  • text

----


  • -->F_ITAB text

----


FORM fill CHANGING f_itab LIKE itab.

DATA f_fill LIKE LINE OF f_itab.

DO 3 TIMES.

f_fill-col1 = sy-index.

f_fill-col2 = sy-index ** 2.

APPEND f_fill TO f_itab.

ENDDO.

ENDFORM. "FILL

&----


*& Form OUT

&----


  • text

----


  • -->VALUE(F_ITAB) text

----


FORM out USING value(f_itab) LIKE itab.

DATA f_fill LIKE LINE OF f_itab.

LOOP AT f_itab INTO f_fill.

WRITE:/ f_fill-col1, f_fill-col2.

ENDLOOP.

ENDFORM. "OUT

Regards,

Bhaskar

Read only

Former Member
0 Likes
11,672

Hi

<u><b>check this for perfrom statement</b></u>

DATA: RNAME(30) VALUE 'WRITE_STATISTIC',   "Form and program 
                                           "names must 
      PNAME(8)  VALUE 'ZYX_STAT'.          "be written in 
                                           "upper case 
PERFORM (RNAME)         IN PROGRAM ZYX_STAT. 
PERFORM WRITE_STATISTIC IN PROGRAM (PNAME). 
PERFORM (RNAME)         IN PROGRAM (PNAME). 

<u><b>You can also</b></u>

PERFORM form ON COMMIT. 

<b>

In the Report write <u>perform</u> and put your cursor on that statement and press F1 you can get number of examples related to it.</b>

<u><b>Check this sample code</b></u>

METHOD if_ex_le_shp_goodsmovement~change_input_header_and_items .

*---------------------------------------------------------------------*
* Internal table declaration
*---------------------------------------------------------------------*

DATA: t_lipsheader TYPE TABLE OF lipsvb .
DATA :t_messtab TYPE TABLE OF bdcmsgcoll.
DATA: t_lipsitem TYPE TABLE OF lipsvb.
DATA :t_bdcdata TYPE TABLE OF bdcdata.

*---------------------------------------------------------------------*
* Structure declaration
*---------------------------------------------------------------------*

DATA: wa_lipsheader TYPE lips.
DATA: wa_likp TYPE likp.
DATA: wa_lips TYPE lipsvb.
DATA: wa_bdcdata TYPE bdcdata.
DATA: wa_messtab TYPE bdcmsgcoll.
DATA: wa_textout TYPE t100-text.


*---------------------------------------------------------------------*
* variable declaration
*---------------------------------------------------------------------*

DATA :fval TYPE bdc_fval.
DATA :ctumode TYPE ctu_params-dismode,
cupdate TYPE ctu_params-updmode.
DATA :date1(10) TYPE c,date2(10) TYPE c.

DATA: budat TYPE sy-datum,
bldat TYPE likp-bldat,
usnam TYPE sy-uname,
uzeit TYPE sy-uzeit,
hhmm(4) TYPE n.

*---------------------------------------------------------------------*
* Constant declaration
*---------------------------------------------------------------------*

CONSTANTS: nodata TYPE c VALUE '/' .
CONSTANTS: c_bwart TYPE lips-bwart VALUE '101'.

* Logic for Posting date and Document date.

* Check for Actual GI date from delivery.
IF is_likp-wadat_ist NE space.
budat = is_likp-wadat_ist.
ELSE.
* If Actual GI date is initial then populate today's date
budat = sy-datum.
ENDIF.

* Populate today's date for document date
bldat = sy-datum.
usnam = sy-uname.



*---------------------------------------------------------------------*
* Start new screen
*---------------------------------------------------------------------*

DEFINE bdc_dynpro.
clear wa_bdcdata.
wa_bdcdata-program = &1.
wa_bdcdata-dynpro = &2.
wa_bdcdata-dynbegin = 'X'.
append wa_bdcdata to t_bdcdata.
END-OF-DEFINITION.

*---------------------------------------------------------------------*
* Insert field
*---------------------------------------------------------------------*

DEFINE bdc_field.
if fval <> nodata.
clear wa_bdcdata.
wa_bdcdata-fnam = &1.
wa_bdcdata-fval = &2.
append wa_bdcdata to t_bdcdata.
endif.
END-OF-DEFINITION.

*---------------------------------------------------------------------*
* loops through the internal table and validates *
* the data in the internal table *
*---------------------------------------------------------------------*

LOOP AT it_xlips INTO wa_lipsheader.

IF wa_lipsheader-uepos IS INITIAL AND wa_lipsheader-pstyv =
'taq' AND wa_lipsheader-oic_mot = 'PK'.

MOVE wa_lipsheader-matnr TO wa_lips-ummat.
MOVE wa_lipsheader-werks TO wa_lips-umwrk.
MOVE wa_lipsheader-werks TO wa_lips-werks.
MOVE wa_lipsheader-lgort TO wa_lips-lgort .
MOVE wa_lipsheader-lgort TO wa_lips-umlgo.
MOVE c_bwart TO wa_lips-bwart.
MOVE wa_lipsheader-posnr TO wa_lips-posnr.
MOVE wa_lipsheader-lfimg TO wa_lips-lfimg.
MOVE wa_lipsheader-meins TO wa_lips-meins.
MOVE wa_lipsheader-volum TO wa_lips-volum.
MOVE wa_lipsheader-vbeln TO wa_lips-vbeln.
MOVE wa_lipsheader-bwtar TO wa_lips-bwtar.

APPEND wa_lips TO t_lipsheader.


ELSE.

IF wa_lipsheader-uepos IS NOT INITIAL AND wa_lipsheader-pstyv
= 'TAE'.

MOVE wa_lipsheader-matnr TO wa_lips-matnr.
MOVE wa_lipsheader-werks TO wa_lips-werks.
MOVE wa_lipsheader-lgort TO wa_lips-lgort.
MOVE wa_lipsheader-lfimg TO wa_lips-lfimg.
MOVE wa_lipsheader-posnr TO wa_lips-posnr.
MOVE wa_lipsheader-voleh TO wa_lips-voleh.
MOVE wa_lipsheader-meins TO wa_lips-meins.
MOVE wa_lipsheader-volum TO wa_lips-volum.
MOVE wa_lipsheader-vbeln TO wa_lips-vbeln.
MOVE wa_lipsheader-bwtar TO wa_lips-bwtar.

IF wa_lips-lgort IS INITIAL.

wa_lips-lgort = wa_lips-umlgo.

ENDIF.

APPEND wa_lips TO t_lipsitem.


ENDIF.

ENDIF.

ENDLOOP.


*---------------------------------------------------------------------*
* BDC TABLE CONTROL
*---------------------------------------------------------------------*

LOOP AT t_lipsheader INTO wa_lipsheader.

WRITE : bldat TO date1 MM/DD/YYYY,
budat TO date2 MM/DD/YYYY.

bdc_dynpro 'SAPMM07M' '0400'.

bdc_field 'BDC_CURSOR' 'RM07M-LGORT'.

bdc_field 'BDC_OKCODE' '/00' .

bdc_field 'MKPF-BLDAT' date1.

bdc_field 'MKPF-BUDAT' date2.

bdc_field 'MKPF-OIB_BLTIME' hhmm.

bdc_field 'RM07M-BWARTWA' c_bwart.

bdc_field 'RM07M-WERKS' wa_lips-werks.

bdc_field 'RM07M-LGORT' wa_lips-lgort.

bdc_field 'XFULL' 'X'.

bdc_field 'RM07M-WVERS2' 'X'.

bdc_dynpro 'SAPMM07M' '0421'.

bdc_field 'BDC_CURSOR' 'MSEG-WERKS(02)'.

bdc_field 'BDC_OKCODE' '/00'.

bdc_field 'MSEGK-UMWRK' wa_lips-umwrk.

bdc_field 'MSEGK-UMLGO' wa_lips-umlgo.

bdc_field 'MSEGK-UMMAT' wa_lips-ummat.

*---------------------------------------------------------------------*
* Data declaration
*---------------------------------------------------------------------*

DATA:quan(17) TYPE c.
DATA:ftable(20) TYPE c.
DATA:k TYPE n.
MOVE 1 TO k.

LOOP AT t_lipsitem INTO wa_lips WHERE vbeln
= wa_lipsheader-vbeln.


IF sy-subrc = 0.


CONCATENATE 'MSEG-MATNR(' k ')' INTO ftable.

bdc_field ftable wa_lips-matnr.


MOVE wa_lips-lfimg TO quan.

CONCATENATE 'MSEG-ERFMG(' k ')' INTO ftable.

bdc_field ftable quan .


CONCATENATE 'MSEG-LGORT(' k ')' INTO ftable.

bdc_field ftable wa_lips-lgort.


CONCATENATE 'MSEG-CHARG(' k ')' INTO ftable.

bdc_field ftable wa_lips-bwtar.


CONCATENATE 'MSEG-WERKS(' k ')' INTO ftable.

bdc_field ftable wa_lips-werks.


ENDIF.

k = k + 1.


ENDLOOP.


bdc_field 'DKACB-FMORE' 'X'.
bdc_dynpro 'SAPLKACB' '0002'.
bdc_field 'BDC_OKCODE' '=ENTE' .
bdc_dynpro 'SAPLOIB_QCI' '0500'.
bdc_field 'BDC_CURSOR' 'OIB_A08-TDICH'.
bdc_field 'BDC_OKCODE' '=CALC'.

bdc_dynpro 'SAPLOIB_QCI' '0500'.
bdc_field 'BDC_CURSOR' 'OIB_A08-TDICH'.
bdc_field 'BDC_OKCODE' '=CONT'.

bdc_dynpro 'SAPLKACB' '0002'.
bdc_field 'BDC_OKCODE' '=ENTE'.
bdc_dynpro 'SAPLOIB_QCI' '0500'.
bdc_field 'BDC_CURSOR' 'OIB_A08-TDICH'.
bdc_field 'BDC_OKCODE' '=CALC'.

bdc_dynpro 'SAPLOIB_QCI' '0500'.
bdc_field 'BDC_CURSOR' 'OIB_A08-TDICH'.
bdc_field 'BDC_OKCODE' '=CONT'.

bdc_dynpro 'SAPLKACB' '0002'.
bdc_field 'BDC_OKCODE' '=ENTE'.
bdc_dynpro 'SAPMM07M' '0421'.
bdc_field 'BDC_CURSOR' 'MSEG-ERFMG(01)'.
bdc_field 'BDC_OKCODE' '=BU'.
bdc_field 'DKACB-FMORE' 'X'.
bdc_dynpro 'SAPLKACB' '0002'.
bdc_field 'BDC_OKCODE' '=ENTE'.


*set the parametrs for call transaction.
ctumode = 'N'.

cupdate = 'L'.


CALL TRANSACTION 'MB11' USING t_bdcdata MODE ctumode
UPDATE cupdate MESSAGES INTO t_messtab.


LOOP AT t_messtab INTO wa_messtab .

CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = wa_messtab-msgid
msgnr = wa_messtab-msgnr
msgv1 = wa_messtab-msgv1
msgv2 = wa_messtab-msgv2
msgv3 = wa_messtab-msgv3
msgv4 = wa_messtab-msgv4
IMPORTING
message_text_output = wa_textout.

MESSAGE wa_textout TYPE wa_messtab-msgtyp.


ENDLOOP.

ENDLOOP.


ENDMETHOD.

<u><b>Check this link</b></u><b><a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/d1/801aaf454211d189710000e8322d00/content.htm">insert statements in sap</a></b>

Reward all helpfull answers

Regards

Pavan

Message was edited by:

Pavan praveen