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

Script Perform

Former Member
0 Likes
1,022

In sap script i have to get the final amount in words.

I have used

/:Perform get_text in program z_word

/:using &komk-fkwrt(i13)&

/:changing &text&

/:endperform

/:&text&

but i am getting runtime error as there are 2 formal parameters and 4 actual parameters.

Thanks

ALI

9 REPLIES 9
Read only

Former Member
0 Likes
980

Hi ,

check the Form-endform in that program.

its saying u have to pass 4 parameters right now u are passsing only 2 that is FKWRT,Text

Regards

Prabhu

Read only

Former Member
0 Likes
980

Hi,

Number of formal parameters should be equal to that of actual prameteres.

Thanks,

Pramod

Read only

vinod_gunaware2
Active Contributor
0 Likes
980

ou can call an ABAP subroutine from SapScript using the PERFORM statment. You can use this to get data without havning to cnahge the print program. In the examole below NAME is retreived from table SCUSTOM.

SapScript

/:DEFINE &CUST& = '00000021'.

/:PERFORM GET_NAME IN PROGRAM Z_BC460_EX4_HF

/: USING &CUST&

/: CHANGING &NAME&

/:ENDPERFORM.

Dear &NAME&

The ABAP routine

The ABAP routine could be defined as follows:

<b>

IMPORTANT:</b> The structure itcsy must be used for the parameters.

REPORT Z_HENRIKF_SCRIPT_FORM .

TABLES scustom.

FORM get_name tables in_tab structure itcsy out_tab structure itcsy.

read table in_tab index 1.

select single * from scustom

where id = in_tab-value.

if sy-subrc = 0.

read table out_tab index 1.

move scustom-name to out_tab-value.

modify out_tab index sy-tabix.

else.

read table out_tab index 1.

move 'No name' to out_tab-value.

modify out_tab index sy-tabix.

endif.

    • You could also fill the ouput parameter table this way

  • READ TABLE out_par WITH KEY 'NAME1'.

  • out_par-value = l_name1.

  • MODIFY out_par INDEX sy-tabix.

ENDFORM.

Note that if you use more than one parameter you must use Using or Changing before every parameter !

/: PERFORM <form> IN PROGRAM <prog>

/: USING &INVAR1&

/: USING &INVAR2&

......

/: CHANGING &OUTVAR1&

/: CHANGING &OUTVAR2&

......

/: ENDPERFORM

regards

vinod

Read only

Former Member
0 Likes
980

Hi Syed,

can you show the routine in Z_WORD with Parameters.

Do you think the last line in the Script

( /:&text& ) is correct?

Regards, Dieter

Read only

dani_mn
Active Contributor
0 Likes
980

Hi

Write this in parameters.

FORM get_text tables in_tab structure itcsy out_tab structure itcsy.

ENDFORM.

Regards,

Wasim Ahmed

Read only

Former Member
0 Likes
980

check that u have coded the form as :

FORM get_text TABLES IN_PAR STRUCTURE ITCSY

OUT_PAR STRUCTURE ITCSY.

Read only

Former Member
0 Likes
980

check this code.

/: PERFORM GET_calc IN PROGRAM XYZ
/: USING &value1&
/: USING &value2&
/: CHANGING &value3&
/: ENDPERFORM

In program XYZ.
FORM get_calc TABLES in_par STRUCTURE itcsy
out_par STRUCTURE itcsy.
read table in_par for values value1 and 2.
modify Out_par to pass teh calculated value.

rgds,

TM.

Read only

former_member480923
Active Contributor
0 Likes
980

Hi

This is a very simple solution, define a variable before you write the perform code whose length will be equal to the length you have specified in the passing parameter and you pass the variable rather than passing the offset values...... something like this

Define &var1& = &itab-val(10)&
perform <routine> in program Z<prg-name>
using &var1&
changing &ret_var&
endperform.

Hope This Helps

Anirban

Read only

Former Member
0 Likes
980

Hi Syed,

i use perform like this.

in Script:

/: PERFORM ZMEDRUCK01_04 IN PROGRAM Z_FORMULAR_ROUTINEN

/: USING &EKPO-EMATN&

/: CHANGING &GROESWRKST&

/: ENDPERFORM

in Abpa:

FORM ZMEDRUCK01_04 TABLES IN_TAB STRUCTURE ITCSY

OUT_TAB STRUCTURE ITCSY.

*

DATA: MATNR_F LIKE MARA-MATNR VALUE '000000000000000000',

I_F TYPE I,

II_F TYPE I.

*

READ TABLE IN_TAB WITH KEY 'EKPO-EMATN'.

  • Wenn keine Materialbestellung => exit

IF SY-SUBRC <> 0 OR IN_TAB-VALUE = SPACE.

EXIT.

ENDIF.

*

I_F = STRLEN( IN_TAB-VALUE ).

II_F = 18 - I_F.

MATNR_FII_F(I_F) = IN_TAB-VALUE0(I_F).

*

SELECT SINGLE * FROM MARA WHERE MATNR = MATNR_F.

  • Materialnummer ist nicht vorhanden => keine weitere verarbeitung

IF SY-SUBRC <> 0.

EXIT.

ENDIF.

*

READ TABLE OUT_TAB WITH KEY = 'GROESWRKST'.

IF MARA-GROES <> SPACE.

CONCATENATE MARA-GROES MARA-WRKST

INTO OUT_TAB-VALUE SEPARATED BY SPACE.

ELSE.

OUT_TAB-VALUE = MARA-WRKST.

ENDIF.

MODIFY OUT_TAB INDEX SY-TABIX.

*

ENDFORM.

I use allways the tables IN_TAB and OUT_TAB.

Regards, Dieter