10-16-2006 12:53 AM
Hi Gurus,
I have an info object OBJ1 of type NUMC length 5.
OBJ2 of type CHAR of length 7 (Contains values like 2003001, 2003002, 2003003,.. 2003012.
I need to assign the first four chars value in OBJ2 to OBJ1 and the fifth filed in OBJ1 is based on the last three chars value in OBJ2.
If last three chars are 001, 002 or 003, the fifth char in OBJ2 is 1.
If last three chars are 004, 005 or 006, the fifth char in OBJ2 is 2.
If last three chars are 007, 008 or 009, the fifth char in OBJ2 is 3.
If last three chars are 010, 011 or 012, the fifth char in OBJ2 is 4
So OBJ1 need to have values like 20031, 20032, 20033, 20034.
I need to write this routine in update rules
Please help me with code.
Thanks
Regards,
aarthi
aarthi.sap@gmail.com
10-16-2006 1:18 AM
Hi,
Try this..
DATA: BEGIN OF S_STRUC,
FOUR(4),
THREE(3),
END OF S_STRUC.
LOOP AT ITAB_OBJ2.
S_STRUC = ITAB_OBJ2.
OBJ1 = S_STRUC.
IF S_STRUC-THREE = '001' OR S_STRUC-THREE = '002'
OR S_STRUC-THREE = '003'.
OBJ1+4(1) = '1'.
ELSEIF S_STRUC-THREE = '004' OR S_STRUC-THREE = '005'
OR S_STRUC-THREE = '006'.
OBJ1+4(1) = '2'.
ELSEIF S_STRUC-THREE = '007' OR S_STRUC-THREE = '008'
OR S_STRUC-THREE = '009'.
OBJ1+4(1) = '3'.
ELSEIF S_STRUC-THREE = '010' OR S_STRUC-THREE = '011'
OR S_STRUC-THREE = '012'.
OBJ1+4(1) = '4'.
ENDIF.
APPEND OBJ1.
ENDLOOP.
Hope this what you want..
Thanks,
Naren
10-16-2006 1:47 AM
Hi Narendran,
Thanks for your reply.
But, I couldnt understand the usage of loop in your code. I have to write the code in the upate rules.
Can you please help me with the problem in the code.
This update rules is for object of type NUMC of legth 5.
Here the Z_VAL is of type Char of lenght 7.
Depending on the value of the last 3 digits in Z_VAL i have to concatenate the value to the result. In this case when i execute, only the else statement is getting executed. i dont know why the if loop fails.
if COMM_STRUCTURE-/BIC/Z_VAL+4(3) = '1' or
COMM_STRUCTURE-/BIC/Z_VAL+4(3) = '2' or
COMM_STRUCTURE-/BIC/Z_VAL+4(3) = '3'.
concatenate COMM_STRUCTURE-/BIC/Z_VAL(4) '1' into RESULT.
elseif
COMM_STRUCTURE-/BIC/Z_VAL+4(3) = '4' or
COMM_STRUCTURE-/BIC/Z_VAL+4(3) = '5' or
COMM_STRUCTURE-/BIC/Z_VAL+4(3) = '6'.
concatenate COMM_STRUCTURE-/BIC/Z_VAL(4) '2' into RESULT.
elseif
COMM_STRUCTURE-/BIC/Z_VAL+4(3) = '7' or
COMM_STRUCTURE-/BIC/Z_VAL+4(3) = '8' or
COMM_STRUCTURE-/BIC/Z_VAL+4(3) = '9'.
concatenate COMM_STRUCTURE-/BIC/Z_VAL(4) '3' into RESULT.
else.
concatenate COMM_STRUCTURE-/BIC/Z_VAL(4) '4' into RESULT.
Please help me regarding this.
Thanks,
Regards,
aarthi
aarthi.sap@gmail.com
10-16-2006 5:00 AM
Hi,
As mentioned,you need to check all the 3 characters.
if COMM_STRUCTURE-/BIC/Z_VAL+4(3) = '001' or
COMM_STRUCTURE-/BIC/Z_VAL+4(3) = '002' or
COMM_STRUCTURE-/BIC/Z_VAL+4(3) = '003'.
concatenate COMM_STRUCTURE-/BIC/Z_VAL(4) '1' into RESULT.
elseif
COMM_STRUCTURE-/BIC/Z_VAL+4(3) = '004' or
COMM_STRUCTURE-/BIC/Z_VAL+4(3) = '005' or
COMM_STRUCTURE-/BIC/Z_VAL+4(3) = '006'.
concatenate COMM_STRUCTURE-/BIC/Z_VAL(4) '2' into RESULT.
elseif
COMM_STRUCTURE-/BIC/Z_VAL+4(3) = '007' or
COMM_STRUCTURE-/BIC/Z_VAL+4(3) = '008' or
COMM_STRUCTURE-/BIC/Z_VAL+4(3) = '009'.
concatenate COMM_STRUCTURE-/BIC/Z_VAL(4) '3' into RESULT.
else.
concatenate COMM_STRUCTURE-/BIC/Z_VAL(4) '4' into RESULT.
10-16-2006 1:59 AM
Hi,
You have check '001' instead of '1'.
if COMM_STRUCTURE-/BIC/Z_VAL+4(3) = '001' or
COMM_STRUCTURE-/BIC/Z_VAL+4(3) = '002' or
COMM_STRUCTURE-/BIC/Z_VAL+4(3) = '003'.
Thanks,
Naren