‎2010 Feb 17 7:35 AM
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.
‎2010 Feb 17 12:23 PM
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
‎2010 Feb 17 8:21 AM
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.
‎2010 Feb 17 12:23 PM
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
‎2010 Feb 17 12:39 PM
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.