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

CONVERSION LOGIC

Former Member
0 Likes
771

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
710

Hi Divya,

Consider this logic.

Will it suit your requirements.


REPORT zztest_arun .
PARAMETERS : btlamt(18) DEFAULT '0986-03456-01'.

DATA : tmp(2),
       len TYPE i.

*Calculate the Length
len = STRLEN( btlamt ).

len = len - 2.

*Take the last two digits into one variable
tmp = btlamt+len(2).

*If there is 0 follow this logic.
IF tmp CA '0'.

  TRANSLATE tmp USING '0 '.
  CONDENSE tmp NO-GAPS.

  CONCATENATE tmp 'C' INTO tmp.

  btlamt+len(2) =  tmp.

ELSE.
*Write any Logic you need or just display the Bottleamount.

ENDIF.



BREAK-POINT.

WRITE  : / btlamt.

<b>Test this code by giving the Input in the way you want and check the output.</b>

Cheers,

AS

5 REPLIES 5
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
710

I'm lost, I'd like to help, but you are going to have to explain a little clearer.

Regards,

Rich Heilman

Read only

0 Likes
710

hi Rich,

i need to display bottle amount ex: 0987-0345-01

so the last two digits of the materil should be converted to asingle digit where applicable and concatenate with a "c"

ex: 0987-0345-01

01 = 1c

bottle amount = 1c

similarly if there is no zero in material ex:0987-0998-22

in this case how can we write logic and for above case also hw can we write logic

filed name is matnr char 18

regards,

divya

Read only

0 Likes
710

Hi Divya ,

do this.


data : lv_char2 type char2,
       lv_temp type char15
       lv_temp1 type char15,
       lv_temp2 type char3
       lv_amout type char18,
       lv_lenght type i.


split amount at '-' into lv_temp lv_temp1 lv_char2.

translate lv_char2+(1) '0 '.
condense lv_char2 no-gaps.

concatenate lv_char2 'C' into lv_temp3.

lv_char2 = lv_temp3.


concatenate lv_temp lv_temp1 lv_char2 
       into lv_amount
 seperated by '-'.

<b>Please Reward Points & Mark Helpful Answers</b>

To mark Helpful Answers ;click radio Button next to the post.

RadioButtons

<b>o</b> Helpful Answer

<b>o</b> Very helpful Answer

<b>o</b> Problem Solved.

Click any of the above button next to the post; as per the anwers

<b>To close the thread; Click Probelm solved Radio Button next to the post , which u feel is best possible answers</b>

Read only

Former Member
0 Likes
710

Hello Divya,

Can you give clear picture about úr requirement.

Regards,

Vasanth

Read only

Former Member
0 Likes
711

Hi Divya,

Consider this logic.

Will it suit your requirements.


REPORT zztest_arun .
PARAMETERS : btlamt(18) DEFAULT '0986-03456-01'.

DATA : tmp(2),
       len TYPE i.

*Calculate the Length
len = STRLEN( btlamt ).

len = len - 2.

*Take the last two digits into one variable
tmp = btlamt+len(2).

*If there is 0 follow this logic.
IF tmp CA '0'.

  TRANSLATE tmp USING '0 '.
  CONDENSE tmp NO-GAPS.

  CONCATENATE tmp 'C' INTO tmp.

  btlamt+len(2) =  tmp.

ELSE.
*Write any Logic you need or just display the Bottleamount.

ENDIF.



BREAK-POINT.

WRITE  : / btlamt.

<b>Test this code by giving the Input in the way you want and check the output.</b>

Cheers,

AS