Application Development 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: 

Urgent help need with ABAP code

Former Member
0 Kudos

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

4 REPLIES 4

Former Member
0 Kudos

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

Former Member
0 Kudos

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

0 Kudos

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.

Former Member
0 Kudos

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