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: 

subroutine calling for diff internal table n corr work area!!

Former Member
0 Kudos

Hi

i have to call a subroutine for diff internal table and their corr work area ...what shud b the syntax?

for example:

 IF not S_KUNNR[] IS INITIAL.
    IF NOT I_SALES_OPEN[] IS INITIAL.
      SELECT * FROM VBPA
      INTO TABLE I_SHIPTO_VBPA
      FOR ALL ENTRIES IN I_SALES_OPEN
      WHERE VBELN = I_SALES_OPEN-VBELN
      and POSNR = '00000'
      and PARVW = V_PARVW_SH.
    ENDIF.
    LOOP AT I_SHIPTO_VBPA INTO WA_VBPA.
      READ TABLE I_SALES_OPEN INTO WA_SALES_OPEN
                        WITH KEY VBELN =  WA_VBPA-VBELN
                                 POSNR =  '000000' BINARY SEARCH.
      IF SY-SUBRC NE 0.
        DELETE I_SALES_OPEN WHERE VBELN = WA_VBPA-VBELN AND
                                  POSNR = WA_VBPA-POSNR .

        MOVE WA_VBPA-KUNNR TO WA_SALES_OPEN-KUNNR.
        APPEND WA_SALES_OPEN TO I_SALES_OPEN.
        CLEAR WA_SALES_OPEN.
      ENDIF.
    ENDLOOP.
  ENDIF.

in the above eg , i_sales_open and wa_sales_open will vary based on the perform calling it..

pls provide the syntax

Regards

Gunjan

12 REPLIES 12

Former Member
0 Kudos

declare a subroutine like this :

perform <sub name> tables <table name>

The structure selopt is the generic structure used for select options.Fill this structure from I_SALES_OPEN INTERNAL TABLE and pass it to the subroutine.Once this table of the type selopt is filled you can manipulate it inside the subroutine.

for eg :

data :

<tab name> like selopt occurs 0 with header line.

loop at i_sales_open into wa.

<tab name>-low = wa-sales_order.

<tab name>-sign = 'I'.

<tab name>-option = 'EQ'.

append <tab name>.

endloop.

form <sub name> tables <tab name > structure selopt.

*Write your code inside this subroutine.

endform

0 Kudos

HI

ITS JUST INTERNAL TABLE AND WORK AREA THAT I HAVE TO PASS!!

REGARDS

gUNJAN

0 Kudos

you are passing an internal table only.The only difference is that you are passing an internal table of the type selopt which the generic SAP structure for select options.Refer to the above code for your reference.

0 Kudos

AND CORR WORKAREA ALSO NEEDS TO B PASSED SINCE INTERNAL TABLE WILL VARY!!

0 Kudos

no need to pass workarea , just pass internal table and declare work area in that perform as local

perform <form_name> changing it_sales.

0 Kudos

thanks

but while declaring the work area it throws the error..

PERFORM f_get_shipto changing I_SALES_OPEN .

FORM f_get_shipto CHANGING Pi_I_SALES_OPEN.

DATA : wa_VBPA LIKE LINE OF i_SHIPTO_VBPA.

DATA: WA_SALES_OPEN like line of pi_i_sales_open.

endform.

saying pi_i_sales_open is not an internal table..even tried type but no use..

Regards

Gunjan

former_member223537
Active Contributor
0 Kudos

Hi Gunjan

PERFORM f_get_shipto <b>TABLES</b> I_SALES_OPEN .

FORM f_get_shipto <b>TABLES</b> Pi_I_SALES_OPEN STRUCTURE ITAB_LINE . "Here ITAB_LINE is the structure

DATA : wa_VBPA LIKE LINE OF i_SHIPTO_VBPA.

DATA: WA_SALES_OPEN like line of pi_i_sales_open.

endform.

Best regards,

Prashant

0 Kudos

Hi,

TYPES: BEGIN OF T_SALES_OPEN,

vbeln TYPE VBAP-VBELN,

posnr TYPE VBAP-POSNR,

matnr TYPE VBAP-MATNR,

klmeng TYPE VBAP-KLMENG,

meins TYPE VBAP-MEINS,

kwmeng TYPE VBAP-KWMENG,

vrkme TYPE VBAP-VRKME,

kunnr TYPE VBPA-KUNNR,

vdatu TYPE VBAK-VDATU.

TYPES: END OF t_sales_open.

data: i_sales_open type table of t_sales_open.

PERFORM f_get_shipto TABLES I_SALES_OPEN .

FORM f_get_shipto TABLES Pi_I_SALES_OPEN STRUCTURE T_sales_open . "Here ITAB_LINE is the structure

DATA : wa_VBPA LIKE LINE OF i_SHIPTO_VBPA.

DATA: WA_SALES_OPEN like line of pi_i_sales_open.

endform.

why is it so?

regards

gunjan

former_member223537
Active Contributor
0 Kudos

Hi,

TYPES: BEGIN OF T_SALES_OPEN,

vbeln TYPE VBAP-VBELN,

posnr TYPE VBAP-POSNR,

matnr TYPE VBAP-MATNR,

klmeng TYPE VBAP-KLMENG,

meins TYPE VBAP-MEINS,

kwmeng TYPE VBAP-KWMENG,

vrkme TYPE VBAP-VRKME,

kunnr TYPE VBPA-KUNNR,

vdatu TYPE VBAK-VDATU.

TYPES: END OF t_sales_open.

data: i_sales_open type table of t_sales_open.

<b>PERFORM f_get_shipto TABLES I_SALES_OPEN .

FORM f_get_shipto TABLES Pi_I_SALES_OPEN STRUCTURE T_sales_open .

DATA : wa_VBPA type T_sales_open .

DATA: WA_SALES_OPEN type T_sales_open .</b>

endform.

Best regards,

Prashant

0 Kudos

since the perform will have several internal table so i cant just put the work area type as t_sales_open as next time the perform will call i_del_open which has diff type and hence diff work area..so what shall i do?

how to pass the diff internal table?

Regards

gunjan

0 Kudos

problem comes when i declare the work area it fails to recognise the pi_sales_open table and says no type defined for the table!!

Regards

Gunjan

former_member223537
Active Contributor
0 Kudos

Hi Gunjan,

<b>PERFORM f_get_shipto TABLES I_SALES_OPEN .

PERFORM f_get_shipto TABLES I_DEL_OPEN .

FORM f_get_shipto TABLES Pi_I_SALES_OPEN.

  • Here P_I_SALES_OPEN will have different structures during the 1st and 2nd call.</b>

DATA : wa_VBPA type T_sales_open .

DATA: WA_SALES_OPEN type T_sales_open .

endform.

Best regards,

Prashant