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

String length comparison

Former Member
0 Likes
995

Hi Friends,

the following logic  Aim is to compare po and item number,and if it get matched,then it will check the description,and the description without space will be getting deleted

i HAVE USED STRING LENGTH functioN.Can you pls tell the elow code will be work fine for my expected output.If not,please modify the code.

If description contain spaces means,it does not do any deletion operation.Say for  po:102 it contain same values in 2 records,but description also contain spaces,so,it should not perform deletion.

DATA:ITAB_src TYPE TABLE OF /BIC/AIPUoitmc00.
DATA:WRKAREA_SRC TYPE /BIC/AIPUoitmc00.

COUNT=0
LOOP AT ITAB_SRC INTO WRKAREA_SRC

LOOP AT ITAB1_SRC INTO WRKAREA1_SRC WHERE EBELN=WRKAREA_src-EBELN AND EBELP=WRKAREA_src-EBELP.

count=count+1

IF COUNT > 1

I=STRLEN(WRKAREA_SRC-PROD_DESCR);
J=STRLEN(WRKARE_SRC-PROD_DESCR);

IF(I>J)
DELETE WRKAREA_SRC

ELSE
DELETE WRKAREA1_SRC;

IF(I==J)

CONTINUE.
ENDIF.
ENDIF
ELSE IF COUNT >1

CONTINE
END LOOP
END LOOP

POITEMDESC
1001WASHING MACHINE
1001WASHINMACHINE
1011FRIDGE
1022AC
1023VACCUM CLEANER
1023VACCUM CLEANER

Expected output:

POITEMDESC
1001WASHING MACHINE
1011FRIDGE
1022AC
1023VACCUM CLEANER
1023VACCUM CLEANER
5 REPLIES 5
Read only

roberto_vacca2
Active Contributor
0 Likes
882

Hi.

Try this:

COUNT = 0.

LOOP AT ITAB_SRC INTO WRKAREA_SRC.

   LOOP AT ITAB1_SRC INTO WRKAREA1_SRC WHERE EBELN = WRKAREA_src-EBELN AND EBELP = WRKAREA_src-EBELP.

     count = count + 1.

     IF COUNT GT 1.

       FI = STRLEN( WRKAREA_SRC-PROD_DESCR ).

       FJ = STRLEN( WRKAREA1_SRC-PROD_DESCR ).

       IF FI LT FJ.

         DELETE  TABLE ITAB1_SRC FROM WRKAREA_SRC.

       ELSEIF FI EQ FJ.

         CONTINUE.

       ELSE.

         DELETE TABLE ITAB1_SRC FROM WRKAREA1_SRC.

       ENDIF.

     ELSEIF COUNT EQ 1.

       CONTINUE.

     ENDIF.

   ENDLOOP.

ENDLOOP.


Hope to help.

Bye

Read only

0 Likes
882

Whether,the code is correct,it will suits my logic??

Pls tell,if my logic will work correct.

Read only

0 Likes
882

Your logic it's quite correct. You have to adapt to my changes if you want your output.

Your logic suppose to delete those words with no spaces.

But if you put for example a third value as

PO   ITEM      DESCR

100     1          WASH

This will be deleted cause it's supposed that your description can be different only for a space. If you have description that are different for others circumstances, you should analyze better your needs.

Hope to help

Read only

0 Likes
882

Hi,

only one good thing in my condition is,if same po and item number is present,then same descriptions will be present:) one is with space and other is without space.

So,i need to delete without space record.

if both descriptions also contains space,it should not perform deletion

Read only

0 Likes
882

Well so your logic is correct cause if you'll have a field with one or more space, will remain only one description with space, others will be deleted.

Hope to help.

Bye