Application Development and Automation 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: 
Read only

script

Former Member
0 Likes
413

Hi Gurus,

cau you help me how to write logic for below problem

BOTTLEAMOUNT CAUFVD-MATNR CHAR 18

BUT LAST TWO DIGITS OF THE MATERIAL SHOULD BE CONVERTED TO A SINGLE DIGIT WHERE APPLICABLE AND CONCATENATED WITH A "C"

EX: 0986-03456-01

01 = 1C THEN

BOTTLE AMOUNT = 1C (IF ITS ZERO HERE )

IF ITS NOT ZERO THERE THEN WHTS THE LOGIC I HAVE WRITE FOR ABOVE 2 CONDITIONS

PLZ REVERT BACK ME

THANKS & REGARDS

DIVYA

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
381

Check this sample code

data:

bottleamount like caufvd-matnr,

v_whole_length type i,

v_substring_length type i,

material_1(16),

material_2(2).

data:

begin of i_material_split occurs 0,

material(18) type c,

end of i_material_split.

move '0986-03456-01' to bottleamount.

v_whole_length = strlen( bottleamount ).

if v_whole_length gt 2.

v_substring_length = v_whole_length - 2.

material_2 = bottleamount+v_substring_length(2).

material_1 = bottleamount+0(v_substring_length).

write 😕 material_1, material_2.

endif.

*-another alternative using SPLIT

split bottleamount at '-' into table i_material_split.

loop at i_material_split.

write:/ i_material_split-material.

endloop.

*-you can then concatenate

2 REPLIES 2
Read only

Former Member
0 Likes
382

Check this sample code

data:

bottleamount like caufvd-matnr,

v_whole_length type i,

v_substring_length type i,

material_1(16),

material_2(2).

data:

begin of i_material_split occurs 0,

material(18) type c,

end of i_material_split.

move '0986-03456-01' to bottleamount.

v_whole_length = strlen( bottleamount ).

if v_whole_length gt 2.

v_substring_length = v_whole_length - 2.

material_2 = bottleamount+v_substring_length(2).

material_1 = bottleamount+0(v_substring_length).

write 😕 material_1, material_2.

endif.

*-another alternative using SPLIT

split bottleamount at '-' into table i_material_split.

loop at i_material_split.

write:/ i_material_split-material.

endloop.

*-you can then concatenate

Read only

0 Likes
381

check this sample code..

data: matnr like mara-matnr,

var type i,

var1 type i.

matnr = '000000000045608'.

var = strlen( matnr ).

var1 = var - 2.

if matnr+var1(1) = 0.

var1 = var1 + 1.

concatenate matnr+var1(1) 'C' into matnr.

write:/ matnr.

else.

*- write ur logic here

endif.