Skip to Content
author's profile photo Former Member
Former Member

Calling subroutine program from script

Hi,

I am calling a subrouting program from a script. Actually i should pass a parameter to the form and need to get back a internal table values. It's going to dump when i execute the script, saying too many parameters specified with perform. Please find my coding below

Script:

/: BREAK-POINT.

/* Define Variables

/: DEFINE &INVAR1& = '0000271151'.

/: DEFINE &OUTVAR1& = ' '

/: DEFINE &MATTOT& = ' '

/: DEFINE &VAMTTOT& = ' '

/: DEFINE &VTAXTOT& = ' '

/: DEFINE &TAXSA& = ' '

/: DEFINE &PLANT& = ' '

/: DEFINE &FMATTOT& = ' '

/: DEFINE &FVAMTTOT& = ' '

/: DEFINE &FVTAXTOT& = ' '

/: DEFINE &FTAXSA& = ' '

/: DEFINE &NUM& = '1'

/: DEFINE &GT_CONS_LST_F& = ''

/E CALL THE ROUTINE

/: PERFORM FETCH_CONSIGN_DATA IN PROGRAM ZMM_CONSIGN_SUBROUTINE_POOL

/: USING &INVAR1&

/: TABLES &GT_CONS_LST_F&

/: ENDPERFORM.

Program:

PROGRAM ZMM_CONSIGN_SUBROUTINE_POOL.

&----


*& Form fetch_consign_data

&----


  • text

----


  • --> in_tab text

  • <-- out_tab text

----


*FORM fetch_consign_data TABLES in_tab STRUCTURE itcsy

  • out_tab STRUCTURE itcsy.

FORM fetch_consign_data USING invar1 TYPE ELIFN

TABLES gt_cons_lst_f.

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

  • tables *

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

TABLES: RKWA,

T001W,

MAKT,

MARD,

BSEG.

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

  • T Y P E S *

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

types: begin of it_cons_list,

werks type RKWA-WERKS,

name1 type T001W-NAME1,

matnr type RKWA-MATNR,

maktx type MAKT-MAKTX,

bstmg type RKWA-BSTMG,

bwaer type RKWA-Bwaer,

wrbtr type RKWA-WRBTR,

curr type RKWA-BSTME,

klabs type MARD-KLABS,

taxsa type RKWA-WRBTR,

taxpv type RKWA-WRBTR,

totpv type RKWA-WRBTR,

end of it_cons_list.

types: begin of it_plant_desc,

werks type RKWA-WERKS,

name1 type T001W-NAME1,

end of it_plant_desc.

types: begin of it_mat_desc,

matnr type RKWA-MATNR,

maktx type MAKT-MAKTX,

klabs type MARD-KLABS,

end of it_mat_desc.

types: begin of it_gnrl_det,

werks type RKWA-WERKS,

matnr type RKWA-MATNR,

bstmg type RKWA-BSTMG,

wrbtr type RKWA-WRBTR,

end of it_gnrl_det.

types: begin of it_bseg_det,

matnr type BSEG-MATNR,

wrbtr type BSEG-WRBTR,

end of it_bseg_det.

DATA: gt_cons_list TYPE STANDARD TABLE OF it_cons_list,

gt_plant_desc TYPE STANDARD TABLE OF it_plant_desc,

gt_mat_desc TYPE STANDARD TABLE OF it_mat_desc,

gt_gnrl_det TYPE STANDARD TABLE OF it_gnrl_det,

gt_cons_list_f TYPE STANDARD TABLE OF it_cons_list with header line,

gt_bseg_det TYPE STANDARD TABLE OF it_bseg_det,

  • gt_cons_lst_f TYPE STANDARD TABLE OF it_cons_list with header line,

w_cons_temp TYPE it_cons_list,

w_bseg_temp TYPE it_bseg_det,

w_plant_desc TYPE it_plant_desc,

w_mat_desc TYPE it_mat_desc,

i_text TYPE STANDARD TABLE OF tline INITIAL SIZE 0,

w_header LIKE thead,

w_text TYPE tline,

l_isqnt like RKWA-BSTMG,

l_matamt like RKWA-WRBTR.

CONSTANTS: c_par TYPE char2 VALUE ',,'. " Sign for tabs

  • Select Plant & material details for the vendor

SELECT werks matnr bstmg wrbtr bwaer

FROM rkwa

INTO CORRESPONDING FIELDS OF TABLE gt_cons_list

  • WHERE lifnr EQ '0000271151'.

WHERE mjahr EQ '2008'.

  • Select Plant & Material description

SELECT werks name1

FROM t001w

INTO CORRESPONDING FIELDS OF TABLE gt_plant_desc

FOR ALL ENTRIES IN gt_cons_list

WHERE werks EQ gt_cons_list-werks.

SELECT amatnr amaktx b~klabs

INTO CORRESPONDING FIELDS OF TABLE gt_mat_desc

FROM ( MAKT as a join MARD as b

ON amatnr EQ bmatnr )

FOR ALL ENTRIES IN gt_cons_list

WHERE a~matnr EQ gt_cons_list-matnr.

  • Get UOM & on-hand values

LOOP AT gt_cons_list INTO w_cons_temp.

LOOP AT gt_plant_desc INTO w_plant_desc.

IF w_plant_desc-werks EQ w_cons_temp-werks.

MOVE w_plant_desc-name1 TO w_cons_temp-name1.

MODIFY gt_cons_list FROM w_cons_temp.

ENDIF.

ENDLOOP.

ENDLOOP.

CLEAR w_cons_temp.

LOOP AT gt_cons_list INTO w_cons_temp.

LOOP AT gt_mat_desc INTO w_mat_desc.

IF w_mat_desc-matnr EQ w_cons_temp-matnr.

MOVE:

w_mat_desc-maktx TO w_cons_temp-maktx,

w_mat_desc-klabs TO w_cons_temp-klabs.

MODIFY gt_cons_list FROM w_cons_temp.

ENDIF.

ENDLOOP.

ENDLOOP.

  • Calcualte tax paid to vendor & total paid to vendor

SELECT MATNR WRBTR

INTO CORRESPONDING FIELDS OF TABLE gt_bseg_det

FROM BSEG

FOR ALL ENTRIES IN gt_cons_list

WHERE MATNR EQ gt_cons_list-MATNR

AND WERKS EQ gt_cons_list-WERKS.

  • "AND LIFNR EQ gt_cons_list-

LOOP AT gt_cons_list INTO w_cons_temp.

LOOP AT gt_bseg_det INTO w_bseg_temp.

w_cons_temp-taxpv = w_bseg_temp-wrbtr - w_cons_temp-wrbtr.

w_cons_temp-totpv = w_cons_temp-wrbtr + w_cons_temp-taxpv.

MODIFY gt_cons_list FROM w_cons_temp.

ENDLOOP.

ENDLOOP.

  • Calculate total issued quantity & material amt as per vendor/plant/material no

LOOP AT gt_cons_list INTO w_cons_temp.

COLLECT w_cons_temp INTO gt_cons_list_f.

CLEAR w_cons_temp.

ENDLOOP.

gt_cons_lst_f = gt_cons_list_f.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Oct 10, 2008 at 05:22 PM

    Hi,

    In the program the FORM should have the following parameters.

    FORM <form> TABLES IN_TAB STRUCTURE ITCSY

    OUT_TAB STRUCTURE ITCSY.

    ENDFORM.

    Check the link for more details.

    http://help.sap.com/saphelp_40b/helpdata/en/d1/803279454211d189710000e8322d00/content.htm

    Thanks

    Naren

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      One more query...

      Actually i am using a script that is not assigned to any driver program.

      I am calling a subroutine program from the script.

      In the subroutine i am calling the function module 'Write_form' within a loop to print line item

      items in the script, but i am not able to get the values in the script.

      One of my colleague told me that we can get the line item values in the script only if the driver program is active. Is it true??

  • author's profile photo Former Member
    Former Member
    Posted on Oct 11, 2008 at 08:39 AM

    Hi,

    In the program

    FORM <form> TABLES IN_TAB STRUCTURE ITCSY
    <IN_TAB> STRUCTURE ITCSY
    <OUT_TAB> STRUCTURE ITCSY
    
    DATA: <PARA1> TYPE <TYPE>,   "Import values
               <PARA2> TYPE <TYPE>,   "Export values
    
    <PARA1> = <IN_TAB>
    "here write the required code to modify the values and to send to subroutine and put taht values in <PARA2>.
    
    finally to send data to subroutine, write
    <OUT_TAB> = <PARA2>
    .

    <form> is subroutine called from the script editor.

    <in_tab> is used to call parameters from subroutine

    <out_tab> is used to export parameters to subroutine

    Regards,

    Dhanunjaya Reddy

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 14, 2008 at 09:17 AM

    When calling abap program in sapscript, all value in using term will be stored in one intenal table and also changing parameter. And you can't passed internal table in sapscript. see below.

    *In form

    PERFORM FORM IN

    /: PERFORM ALAMATAG IN PROGRAM ZXXXXX

    /: USING &IVBDKR-VBELN&

    /: Changing &YYY&

    /: &TLP&

    *in ABAP

    FORM ALAMATAG TABLES CO_USE STRUCTURE CO_SET_TYPE

    CO_SET STRUCTURE CO_SET_TYPE.

    *Get using parameter

    READ TABLE CO_USE WITH KEY NAME = 'VBDKR-VBELN'.

    IF SY-SUBRC EQ 0.

    MOVE CO_USE-VALUE TO NIV.

    ENDIF.

    *Store Changing parameter

    LOOP AT CO_SET.

    IF CO_SET-NAME EQ 'YYY'.

    MOVE YYY TO CO_SET-VALUE.

    MODIFY CO_SET.

    ENDIF.

    IF CO_SET-NAME EQ 'TLP'.

    MOVE TLP TO CO_SET-VALUE.

    MODIFY CO_SET.

    ENDIF.

    ENDLOOP.

    ENDFORM.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.