‎2006 Jun 30 3:48 PM
Hi all,
I need to format the o/p of a data in the script.the requirment is to give 2 spaces after every 2 characters.
for ex:if the data is 'WR56T8' then the o/p format should be 'WR 56 T8'.how can i do it in the script?i am not supposed to change the print program..so i cant use PERFORM in the script..
Thanks..
‎2006 Jun 30 4:02 PM
HI RAKESH,
EVEN IF U CANT CHANGE THE DRIVER PROGRAM U CAN STILL WRITE A PERFORM IN THE SCRIPT as the driver program will be calling ur script.
/: PERFORM get_value IN PROGRAM ZTEST
/: USING VAR1
/: CHANGING VAR2
/: ENDPERFORM.
FORM get-value TABLES IN_TAB STRUCTURE ITCSY
OUT_TAB STRUCTURE ITCSY.
DATA: STR TYPE STRING,
STR1 TYPE STRING,
STR2 TYPE STRING,
STR3 TYPE STRING.
READ TABLE IN_TAB WITH KEY NAME = VAR1.
IF SY-SUBRC = 0.
MOVE IN_TAB-VALUE TO str.
ENDIF.
str1 = str+0(2).
str2 = str+2(4).
str3 = str+4(6).
concatenate str1 str2 str3 into var2 separated by space.
READ TABLE OUT_TAB WITH KEY NAME = VAR2.
IF SY-SUBRC = 0.
MOVE VAR2 TO OUT_TAB-VALUE.
MODIFY OUT_TAB INDEX SY-TABIX.
ENDIF.
ENDFORM.
so whenever ur form is called and when the cursor goes to perform stmt it will go to the program ZTEST and execute.
‎2006 Jun 30 3:56 PM
You use perform ONLY in case where you can't change the print program.
So you can use the perforsm in sap script.
/: PERFORM convert IN PROGRAM Ztest
/: USING &INPUT&
/: CHANGING &OUTPUT&
/: ENDPERFORM
in ztest:
FORM convert TABLES sap_data STRUCTURE itcsy
abap_data STRUCTURE itcsy.
DATA: V_OUTPUT(8).
READ TABLE sap_data WITH KEY name = 'INPUT'.
IF sy-subrc EQ 0.
CONCATENATE INPUT+0(2)
INPUT+2(2)
INPUT+4(2)
INTO V_OUTPUT SEPARATED BY SPACE.
ENDIF.
CONDENSE V_OUTPUT NO-GAPS.
READ TABLE abap_data WITH KEY name = 'OUTPUT'.
IF sy-subrc EQ 0.
abap_data-value = V_OUTPUT.
MODIFY abap_data INDEX sy-tabix.
ENDIF.
ENDFORM.
‎2006 Jun 30 4:02 PM
HI RAKESH,
EVEN IF U CANT CHANGE THE DRIVER PROGRAM U CAN STILL WRITE A PERFORM IN THE SCRIPT as the driver program will be calling ur script.
/: PERFORM get_value IN PROGRAM ZTEST
/: USING VAR1
/: CHANGING VAR2
/: ENDPERFORM.
FORM get-value TABLES IN_TAB STRUCTURE ITCSY
OUT_TAB STRUCTURE ITCSY.
DATA: STR TYPE STRING,
STR1 TYPE STRING,
STR2 TYPE STRING,
STR3 TYPE STRING.
READ TABLE IN_TAB WITH KEY NAME = VAR1.
IF SY-SUBRC = 0.
MOVE IN_TAB-VALUE TO str.
ENDIF.
str1 = str+0(2).
str2 = str+2(4).
str3 = str+4(6).
concatenate str1 str2 str3 into var2 separated by space.
READ TABLE OUT_TAB WITH KEY NAME = VAR2.
IF SY-SUBRC = 0.
MOVE VAR2 TO OUT_TAB-VALUE.
MODIFY OUT_TAB INDEX SY-TABIX.
ENDIF.
ENDFORM.
so whenever ur form is called and when the cursor goes to perform stmt it will go to the program ZTEST and execute.