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

SAP SCRIPT Perform statement issue

Former Member
0 Likes
565

Hi,

i have modified one sap standard sap scrip. i m adding some addition fields . using perform statement in sapscript . but my perform statement is not working . please someone help me .

thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
476

Please check the below sample code to call a subroutine from script

Code to be written in script

/: PERFORM F0110_GET_AMOUNT IN PROGRAM ZTEST

/: USING &RF140-WRSHB&

/: CHANGING &L_AMOUNT&

/: ENDPERFORM

Code to be writetn in subroutine pool ZTEST

FORM f0110_get_amount TABLES l_input_table STRUCTURE itcsy

l_output_table STRUCTURE itcsy.

DATA: l_amount(22) TYPE c,

l_length TYPE i.

READ TABLE l_input_table WITH KEY name = 'RF140-WRSHB'.

IF sy-subrc = 0.

l_amount = l_input_table-value.

ENDIF.

l_amount = l_amount * 100.

CLEAR l_output_table.

READ TABLE l_output_table WITH KEY name = 'L_AMOUNT'.

IF sy-subrc = 0.

MOVE l_amount TO l_output_table-value.

MODIFY l_output_table INDEX sy-tabix.

ENDIF.

ENDFORM. "F0110_GET_AMOUNT

3 REPLIES 3
Read only

Former Member
0 Likes
476

You have to supply more information. How have you coded your PERFORM staement? Is it executed or bypassed within the SAPScript?

To test you can simply output a text such as 'before perform' and 'after perform' before and after your PERFORM statement. Narrow down the problem as best as you can.

Read only

Former Member
0 Likes
477

Please check the below sample code to call a subroutine from script

Code to be written in script

/: PERFORM F0110_GET_AMOUNT IN PROGRAM ZTEST

/: USING &RF140-WRSHB&

/: CHANGING &L_AMOUNT&

/: ENDPERFORM

Code to be writetn in subroutine pool ZTEST

FORM f0110_get_amount TABLES l_input_table STRUCTURE itcsy

l_output_table STRUCTURE itcsy.

DATA: l_amount(22) TYPE c,

l_length TYPE i.

READ TABLE l_input_table WITH KEY name = 'RF140-WRSHB'.

IF sy-subrc = 0.

l_amount = l_input_table-value.

ENDIF.

l_amount = l_amount * 100.

CLEAR l_output_table.

READ TABLE l_output_table WITH KEY name = 'L_AMOUNT'.

IF sy-subrc = 0.

MOVE l_amount TO l_output_table-value.

MODIFY l_output_table INDEX sy-tabix.

ENDIF.

ENDFORM. "F0110_GET_AMOUNT

Read only

Former Member
0 Likes
476

Did you debug.... I wouldn't try to calculate a type c (character field). l_amount needs to be type p decimals 2 probably, then coverted back to a character... with a_amount ( of type char17) = p_amount_field.

also, try:

read table in_par index 1...

read table out_par index 1.....

no need to do a lot of convoluted logic to get the row (only one in each table in this case) you want.