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: 

Copy select option into range with inline declaration, divides one record into two

hagit
Active Participant
0 Kudos
1,091

Hello experts,

I have a SELECT-OPTION.

I want to fetch the first 4 character of the low & high values to a range .

The code is:

TABLES: bkpf.
SELECTION-SCREEN BEGIN OF BLOCK blk1.
SELECT-OPTIONS: s_postdy FOR bkpf-budat OBLIGATORY.
SELECTION-SCREEN END OF BLOCK blk1.

TYPES: lrngty_yr_of_posting_dy TYPE RANGE OF bkpf-gjahr.

DATA(lrng_yr_of_posting_dy) =
VALUE lrngty_yr_of_posting_dy(
FOR ls_postdy IN s_postdy[]
LET lv_low_yr = ls_postdy-low(4)
lv_high_yr = ls_postdy-high(4)
IN low = lv_low_yr
high = lv_high_yr
( sign = ls_postdy-sign )
( option = ls_postdy-option )
).

The problem is that one row in the select option is divided into two.

My ABAP's version is 740.7

Thankyou in advanced

Hagit

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor
963

Each pair of brackets means one line. So, if you indicate two pairs of brackets, that will make two rows.

The values before the brackets are factorized to be used by each pair of brackets.

In your code:

DATA(lrng_yr_of_posting_dy) = VALUE lrngty_yr_of_posting_dy(
                              FOR ls_postdy IN s_postdy[]
                              LET lv_low_yr = ls_postdy-low(4)
                                  lv_high_yr = ls_postdy-high(4)
                              IN 
                              low = lv_low_yr
                              high = lv_high_yr
                              ( sign = ls_postdy-sign )
                              ( option = ls_postdy-option )
                              ).

The first line will contain LOW, HIGH and SIGN.

The second line will contain LOW, HIGH and OPTION.

7 REPLIES 7

adityaIngale
Active Participant
963

Hi hagit,

I've modified it a little, and it's working fine now.

TABLES: bkpf.
SELECTION-SCREEN BEGIN OF BLOCK blk1.
SELECT-OPTIONS: s_postdy FOR bkpf-budat OBLIGATORY.
SELECTION-SCREEN END OF BLOCK blk1.

TYPES: lrngty_yr_of_posting_dy TYPE RANGE OF bkpf-gjahr.

DATA(lrng_yr_of_posting_dy) = VALUE lrngty_yr_of_posting_dy(
FOR ls_postdy IN s_postdy[]
LET lv_low_yr = ls_postdy-low(4)
lv_high_yr = ls_postdy-high(4)
IN ( low = lv_low_yr
high = lv_high_yr
sign = ls_postdy-sign
option = ls_postdy-option )
).

0 Kudos
963

Or you can achieve this without using LET IN.

DATA(lrng_yr_of_posting_dy) = VALUE lrngty_yr_of_posting_dy(
FOR ls_postdy IN s_postdy[]
( low = ls_postdy-low(4)
high = ls_postdy-high(4)
sign = ls_postdy-sign
option = ls_postdy-option ) ).

hagit
Active Participant
0 Kudos
963

aditya.ingale Thank you for your answer. It solves the problem.

You and Sandra Rossi have the same solution ,so I do not know which answer to mark as the best one.

Thank you

Hagit

Sandra_Rossi
Active Contributor
0 Kudos
963

Please edit your question (Actions>Edit), select your code and press the button [CODE], which makes the code appear colored/indented, it'll be easier for people to look at it. Thanks!

Sandra_Rossi
Active Contributor
964

Each pair of brackets means one line. So, if you indicate two pairs of brackets, that will make two rows.

The values before the brackets are factorized to be used by each pair of brackets.

In your code:

DATA(lrng_yr_of_posting_dy) = VALUE lrngty_yr_of_posting_dy(
                              FOR ls_postdy IN s_postdy[]
                              LET lv_low_yr = ls_postdy-low(4)
                                  lv_high_yr = ls_postdy-high(4)
                              IN 
                              low = lv_low_yr
                              high = lv_high_yr
                              ( sign = ls_postdy-sign )
                              ( option = ls_postdy-option )
                              ).

The first line will contain LOW, HIGH and SIGN.

The second line will contain LOW, HIGH and OPTION.

hagit
Active Participant
0 Kudos
963

sandra.rossi Thank you for your answer. It solves the problem.

You and Aditya Ingale have the same solution ,so I do not know which answer to mark as the best one.

Thank you

Hagit

0 Kudos
963

The huge difference is the textual explanation. Providing code without explanation is usually not very good... Maybe you don't read, you already knew that or you don't mind understanding how ABAP works, I don't know

(LOL)