Wednesday, February 24, 2010

As Simple As SY-ABCDE!

1. In a character string where you want to check whether a string contains any alphabets, try using this one!

    e.g. TRANSLATE lv_var TO UPPERCASE.
           IF lv_test CA sy-abcde.                            "Contains Any A to Z
           .........

SY-ABCDE only checks for CAPITALS A-Z, hence the need to translate the variable to uppercase first.

2. To check whether a char datatype variable contains only numeric characters or not, use this:

    e.g. IF lv_var CN '1234567890.'               "Doesn't contain 0 to 9 and decimal point (.)           .........

You might as well use sy-abcde to check if user has keyed in other than numerics characters, but it is safer to use the latter (1234567890.) because there is possibility that user might key in symbols as well.

NOTES: Logical Expressions for String Fields

CO - Contains
CN - Does Not Contain / Inverse of Contains
CA - Contains Any
NA - Contains None / Inverse of Contains Any
CS - Contains String
NS - Does Not Contain String / Inverse of Contains String
CP - Contains Pattern
NP - Does Not Contain Pattern / Inverse of Contains Pattern




With Much Love,

The Rookie ABAPer

Dealing With Multiple Copies

Scenario: There are times when the client wanted to print 4 copies for each of their Delivery Order (DO) form (all with the same DO number). They want different texts to be printed on each of the 4 copies.

Solution:

1. Create a new window with the Window Type - 'Copies Window'.

2. Select 'Only Copies - Copies Differ'.

3. Insert program lines or texts under the node, as in my case:

    - page 1 should print 'Delivery Copy'
    - page 2 should print 'Warehouse Copy'
    - page 3 should print 'Vendor Copy'
    - page 4 should print 'Area Manager Copy'

4. The current 'Copy Number' can be obtained using &SFSY-COPYCOUNT&.

5. Or if you don't want to refer to it directly so you can manipulate it in you program line, just declare a global variable and move the value to your own variable, e.g:

    @Global Definitions:
        gv_copycount LIKE sfsy-copycount.

    @Program Lines:
       MOVE sfsy-copycount TO gv_copycount. 
       IF gv_copycount = '001'.
         gv_copytext = 'Delivery Copy'.
       ENDIF.


With Much Love,
The Rookie ABAPer

HELLO WORLD!

I created this blog simply as a platform for sharing my own ABAP & SAP notes with you, you and you!

We all know that GOOGLE is the tool! Most of the time, especially when you're already familiar with the SAP environment, most ABAP stuff can be found on the net! I wouldn't say if you're really new in this field, Google will be much of a help, because it won't. You have to learn it from the Gurus :)

The trick is just to google it up with the BEST KEYWORD you could think of, then wallah! It's all there!

And if I've learnt anything in the past on ABAP, it would be about not reinventing the wheel. Most of the obstacles you had in ABAP was already faced by others, so it's the matter of finding the right keyword, hence the right solution. It's very unlikely that you're facing some truly unique problems! :)

So, I'll just write anything I figure would be useful here, as it is very likely that these things will be revisited next time around! The time when I may have forgotten the solutions, or the time when I've ran out of keywords to google.

Sooooooo, happy learning, and stay optimist (and cute!) haha.


With Much Love,
The Rookie ABAPer