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: 

How can I concatenate select options value to another select options value.

0 Kudos

like::

doc no: 556777 up to 556780

year: 2018.

how can I concatenate doc no. 556777 to 556780, to 2018.

the output i want is

5567772018

5567782018

5567792018

5567802018

is there a way to do such? thank you!

table: bkpf.

SELECT-OPTIONS: S_BUKRS FOR BKPF-BUKRS NO-EXTENSION NO INTERVALS OBLIGATORY DEFAULT '1000', "Company Code
S_BELNR FOR BKPF-BELNR ,"OBLIGATORY, "Doc Number
"s_date FOR bkpf-budat NO-EXTENSION NO INTERVALS OBLIGATORY, "DN Date
S_GJAHR FOR BKPF-GJAHR NO-EXTENSION NO INTERVALS DEFAULT SY-DATUM(4) OBLIGATORY. "Fiscal 
DATA: IT TYPE STRING.


CONCATENATE S_BELNR S_GJAHR INTO IT.

WRITE: / IT.
1 ACCEPTED SOLUTION

jangold
Explorer

Hi Karlvin.

I do not understand why you are using select options instead of parameters at least for the year.

If you enable extension on S_BELNR than you will have to loop the range table but this will be not so easy. Read more informations about fields SIGN, OPTION!

JG

TABLES:
  bkpf
  .
SELECT-OPTIONS:
  s_bukrs FOR bkpf-bukrs NO-EXTENSION NO INTERVALS OBLIGATORY DEFAULT '1000', "Company Code
  s_belnr FOR bkpf-belnr NO-EXTENSION OBLIGATORY
  .
PARAMETER p_ghjahr LIKE bkpf-gjahr DEFAULT sy-datum(4) OBLIGATORY. "Fiscal

DATA:
  it_concats TYPE TABLE OF string,
  ls_concats TYPE string,
  lv_belnr   LIKE bkpf-belnr
  .


IF s_belnr-high IS INITIAL.
  CONCATENATE s_belnr-low p_ghjahr INTO ls_concats.
  APPEND ls_concats TO it_concats.
ELSE.
  lv_belnr = s_belnr-low.
  WHILE lv_belnr LE s_belnr-high.
    CONCATENATE lv_belnr p_ghjahr INTO ls_concats.
    APPEND ls_concats TO it_concats.
    ADD 1 TO lv_belnr.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        input  = lv_belnr
      IMPORTING
        output = lv_belnr.
  ENDWHILE.
ENDIF.

LOOP AT it_concats INTO ls_concats.
  WRITE: / ls_concats.
ENDLOOP.
4 REPLIES 4

former_member564522
Active Participant
0 Kudos

Hi Karlvin,

It is not possible to just merge two Select-options into 1 . Select options are itself a internal table .

You have to loop table with nesting to have concatenation of MxN.

jangold
Explorer

Hi Karlvin.

I do not understand why you are using select options instead of parameters at least for the year.

If you enable extension on S_BELNR than you will have to loop the range table but this will be not so easy. Read more informations about fields SIGN, OPTION!

JG

TABLES:
  bkpf
  .
SELECT-OPTIONS:
  s_bukrs FOR bkpf-bukrs NO-EXTENSION NO INTERVALS OBLIGATORY DEFAULT '1000', "Company Code
  s_belnr FOR bkpf-belnr NO-EXTENSION OBLIGATORY
  .
PARAMETER p_ghjahr LIKE bkpf-gjahr DEFAULT sy-datum(4) OBLIGATORY. "Fiscal

DATA:
  it_concats TYPE TABLE OF string,
  ls_concats TYPE string,
  lv_belnr   LIKE bkpf-belnr
  .


IF s_belnr-high IS INITIAL.
  CONCATENATE s_belnr-low p_ghjahr INTO ls_concats.
  APPEND ls_concats TO it_concats.
ELSE.
  lv_belnr = s_belnr-low.
  WHILE lv_belnr LE s_belnr-high.
    CONCATENATE lv_belnr p_ghjahr INTO ls_concats.
    APPEND ls_concats TO it_concats.
    ADD 1 TO lv_belnr.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        input  = lv_belnr
      IMPORTING
        output = lv_belnr.
  ENDWHILE.
ENDIF.

LOOP AT it_concats INTO ls_concats.
  WRITE: / ls_concats.
ENDLOOP.

0 Kudos

Thank you!! You're a Legend Man. thanks!!

horst_keller
Product and Topic Expert
Product and Topic Expert

Dare to use F1on SELECT-OPTIONS!