2023 Jul 02 10:47 AM
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
2023 Jul 02 7:07 PM
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.
2023 Jul 02 5:57 PM
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 )
).
2023 Jul 02 6:05 PM
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 ) ).
2023 Jul 03 7:10 AM
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
2023 Jul 02 7:03 PM
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!
2023 Jul 02 7:07 PM
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.
2023 Jul 03 7:08 AM
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
2023 Jul 03 9:28 AM
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)