Application Development 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: 

captch real value from select-option field while executing program

Former Member
0 Kudos

Hello all,

              I am working on a simple report but facing an problem in it.

SELECTION-SCREEN BEGIN OF BLOCK B1.

       SELECT-OPTIONS :  M_NO for MSEG-MATNR,

                     M_YEAR FOR MSEG-MJAHR.

       SELECTION-SCREEN END OF BLOCK B1.

    DATA : LEN TYPE I.

    LEN = STRLEN( M_NO ).

  WRITE: LEN.

  when I select record for eg. if i select value 18 in m_no then LEN should display value 2.bute its showing 21.I have debuge the program M_NO taking the value 'AEQ000000000000000018'.can anyone please help me with this problem.

Thanks in advance.

1 ACCEPTED SOLUTION

yogendra_bhaskar
Contributor
0 Kudos

Hi sam ,

As you have declared M_NO as matnr , hence its length will be 18 by default.

and you have to get value you need to use M_NO-LOW for it .

Try this code

SELECTION-SCREEN BEGIN OF BLOCK B1.

        SELECT-OPTIONS M_NO for MSEG-MATNR,

                      M_YEAR FOR MSEG-MJAHR.

        SELECTION-SCREEN END OF BLOCK B1.

     DATA : LEN TYPE I.

     shift M_NO-low LEFT DELETING LEADING '0' .

     LEN = STRLEN( M_NO-low ).

     WRITE: LEN.


Regards


Yogendra Bhaskar

4 REPLIES 4

yogendra_bhaskar
Contributor
0 Kudos

Hi sam ,

As you have declared M_NO as matnr , hence its length will be 18 by default.

and you have to get value you need to use M_NO-LOW for it .

Try this code

SELECTION-SCREEN BEGIN OF BLOCK B1.

        SELECT-OPTIONS M_NO for MSEG-MATNR,

                      M_YEAR FOR MSEG-MJAHR.

        SELECTION-SCREEN END OF BLOCK B1.

     DATA : LEN TYPE I.

     shift M_NO-low LEFT DELETING LEADING '0' .

     LEN = STRLEN( M_NO-low ).

     WRITE: LEN.


Regards


Yogendra Bhaskar

raymond_giuseppi
Active Contributor
0 Kudos

The field MATNR carry a CONVERSION-EXIT,

External format (what you see/input) differs from internal value (field value in program, database)

So check domain MATNR to get correct conversion-exit (it is not always ALPHA, and there is at least one available customer exit available...) and use the associated FM to get external value (e.g. CONVERSION_EXIT_MATN1_OUTPUT, CONVERSION_EXIT_ALPHA) or a simple WRITE INTO statement to get back external value.

Also records of a RANGE/SELECT OPTIONS have a generic structure :

SIGN (Inclide/Exclude) OPTION (EQ, BT, etc.) LOW and HIGH, here you could check LOW value for EQ and LOW and HIGH for BT.

Why do you require this information, curiosity ?

Regards,

Raymond

0 Kudos

Hi,

You can use

CONVERSION_EXIT_ALPHA_OUTPUT

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'

  EXPORTING

    input         = M_NO-low

IMPORTING

    OUTPUT        = M_NO-low.

and then

LEN = STRLEN( M_NO-low ).

Former Member
0 Kudos

Thanks all.Its working now.