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

Code with string syntax "cn"

Former Member
0 Likes
3,278

A developer put this custom code inside a DocSave rtn for deliveries in SAP. During my interface build I am trying to update a delivery, and nothing I put in sy-tcode here in debug prevents it from dropping into the loop?

This part of the SAP logic does not have uom in field xlips-GEWEI so I always get this err msg. Anybody have an idea what the developer was trying to accomplish here before I change it. And, what would sy-tcode have to be equal to in order to avoid going into this logic?

Thank-You

if sy-tcode cn 'VL02*'.
    loop at xlikp.
      loop at xlips where vbeln = xlikp-vbeln.
        if xlips-gewei is initial and
           ( not xlips-ntgew is initial or
           not xlips-brgew is initial ).
          message id 'VL' type 'A' number '001'
              with 'UNIT OF MEASURE MISSING'.
        endif.
      endloop.
    endloop.
  endif.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,968

The user is aborting the processing if there is some weight (net weight - ntgew or gross weight - brgew )

and the unit of measure( gewei ) is missing.

And the if condition is for CN(Contains not only).

The correct way to avoid the block for 'VL02' is:

data: lv_tcode type tcode value 'VL02'.

if sy-tcode cn lv_tcode.

endif.

Thanks,

Chandra Indukuri

5 REPLIES 5
Read only

Former Member
0 Likes
1,968

Hi,

This is the standard SAP documentation for 'CN'.

CO (Contains Only):

c1 contains only characters from the string c2.

If c1 or c2 is of type C, the comparison takes into account the full length of the field, including blanks at the end.

comparison.

If c1 is of type STRING and empty, the result of the comparison is always positive.

If c2 is of type STRING and empty, the result of the comparison is always negative, unless c1 is also an empty string.

If the result of the comparison is negative, the field SY-FDPOS contains the offset of the first character in c1 which is not also included in c2.

If the result of the comparison is positive, the system field SY-FDPOS contains the length of c1.

The comparison is case-sensitive.

Examples:

'ABCDE' CO 'XYZ' is false; SY-FDPOS = 0.

'ABCDE' CO 'AB' is false; SY-FDPOS = 2.

'ABCDE' CO 'ABCDE' is true; SY-FDPOS = 5.

CN (Contains Not only):

"c1 CN c2" is equivalent to " NOT ( c1 CO c2 )".

c1 contains not only characters from c2.

If the result of the comparison is positive, the system field SY-FDPOS contains the offset of the first character in c1 which is not also in c2.

If the result of the comparison is negative, the system field SY-FDPOS contains the length of c1.

The logic will be executed for all tcodes. It will not execute if tcode contains 'VL02*'.

Read only

Former Member
0 Likes
1,968

Hi,

Your developer is initially checking transaction code. if the transaction code either VL02 or VL02N then he is proceeding to check the weights.

first checking the sales order in header and item level. if it is equal then

he is checking volume(GEWEI). if it is empty and checking net weight(NTGEW) and gross weight(BRGEW). if any of weights is not empty then he is displaying the error message stating that "Unit of Measure is missing".

Edited by: subas Bose on Mar 31, 2010 6:56 PM

Read only

0 Likes
1,968

Subas,

Its a hard value 'VL02*'. If the developer wanted to execute the logic for VL02 or VL02N, he should have used "CS" instead of CN. Isn't it?

IF sy-tcode CS 'VL02'.

execute logic.

endif.

This would execute for both VL02 and VL02N.

Read only

Former Member
0 Likes
1,969

The user is aborting the processing if there is some weight (net weight - ntgew or gross weight - brgew )

and the unit of measure( gewei ) is missing.

And the if condition is for CN(Contains not only).

The correct way to avoid the block for 'VL02' is:

data: lv_tcode type tcode value 'VL02'.

if sy-tcode cn lv_tcode.

endif.

Thanks,

Chandra Indukuri

Read only

0 Likes
1,968

My main concern was the cn 'VL03*' as I understand the wt and uom parts. However, I do not care what is in sy-tcode, everything will validate past that, it was, as some of you have said, I believe coded incorrectly.

Thanks, Tom