‎2007 Jan 27 11:17 AM
Hi all,
I have a requirement where in if the value of the variable is between 888888 to 88888888 a ' 6 ' should be padded in front of it. So now the variable value would be like 6888888 to 688888888. The problem is the value gets stored in the database with zeros appended to it. i.e if the length of the variable is 18, 888888 will be stored as 000000000000888888 in the database and from this it has to be converted into 000000000006888888.
Any inputs on how this can be done.
Regards,
Neo.
‎2007 Jan 27 11:35 AM
hi first fetch all the values into your internal table field
then to remove the leading zeroes use the function module
convert_exit_alpha_output
otherwise u can use
SHIFT VALUE LEFT DELETING LEADING '0'.
next comes to find ur value whether it between 888888 to 88888888
for this use if condition
if value < 88888888 and value > 888888.
<logic>
endif.
the ending would be ur logic, that is to append 6 in front of it
concatenate '6' value into value.
this will solve ur problem , award points if found helpful
‎2007 Jan 27 11:35 AM
hi first fetch all the values into your internal table field
then to remove the leading zeroes use the function module
convert_exit_alpha_output
otherwise u can use
SHIFT VALUE LEFT DELETING LEADING '0'.
next comes to find ur value whether it between 888888 to 88888888
for this use if condition
if value < 88888888 and value > 888888.
<logic>
endif.
the ending would be ur logic, that is to append 6 in front of it
concatenate '6' value into value.
this will solve ur problem , award points if found helpful
‎2007 Jan 27 11:37 AM
Hi
U can try something like this:
PARAMETERS: P(18) TYPE C
.
DATA: VAL1(18) VALUE '888888',
VAL2(18) VALUE '88888888'.
IF P => VAL1 AND P <= VAL2.
PERFORM CONVERT_DATA USING P.
ENDIF.
*&---------------------------------------------------------------------*
*& Form CONVERT_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_VAL text
*----------------------------------------------------------------------*
FORM CONVERT_DATA USING P_VAL.
DATA: VAL(18).
DATA: LEN TYPE I.
LEN = STRLEN( P_VAL ).
VAL(1) = '6'.
VAL+1 = P_VAL(LEN).
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = VAL
IMPORTING
OUTPUT = P_VAL.
WRITE:/ P_VAL.
ENDFORM. " CONVERT_DATAMax
‎2007 Jan 27 11:56 AM
Hi Neo,
The following code will help you out.
text = '000000000000888888'.
SHIFT text LEFT DELETING LEADING '0'.
CONDENSE text NO-GAPS.
Reward points if helped.
Best Regards
Renjan
‎2007 Jan 27 12:16 PM
Hi Neo,
probably you are handling material numbers, they have 18 digits
000000000000888888
Thats means, you have 10, 11 or 12 leading zeroes.
You can use the conversion method like
replace:
'000000000000' with '000000000006' in <matnr>.
check sy-subrc <> 0.
'00000000000' with '00000000006' in <matnr>.
check sy-subrc <> 0.
'0000000000' with '0000000006' in <matnr>.
This is pattern-based: If the first replacement fails because there are no 12 leading zeroes, the second will try to replace 11 leading zeroes, if this fails, the third statement should find 10 leading zeroes.
<b>You did not mention where you want to do the replacement: If this is planned for SAP standard tables then you should be aware that you do not know where else the numbers may be referenced - sales, purchases, storage, archive: Everything may be involved.
</b>
Regards,
Clemens