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: 

Need two ebeln in one column

Former Member
0 Kudos

Hi,

I want ekbe-ebeln and bsik-ebeln in one column.

Can anyone suggest the solution.

IF it_with_item-blart EQ 'RE'.

      SELECT SINGLE ebeln gjahr belnr
         FROM ekbe INTO (it_with_item-ebeln,it_with_item-gjahr1,it_with_item-belnr1)
      WHERE gjahr = it_with_item-awkey+10(4) AND belnr = it_with_item-awkey(10).
      MODIFY it_with_item TRANSPORTING:ebeln.
    ENDIF.
    READ TABLE it_bsik WITH KEY bukrs = it_with_item-bukrs belnr = it_with_item-belnr gjahr = it_with_item-gjahr.
    IF sy-subrc = 0.
      it_with_item-ebeln it_bsik-ebeln.
      it_with_item-zuonr it_bsik-zuonr.
      MODIFY it_with_item TRANSPORTING:ebeln,zuonr.
    ENDIF.

Regards

Kalpana

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

I solved my problem using If.. else condition.

IF it_with_item-blart EQ 'RE'.
      SELECT SINGLE ebeln gjahr belnr
         FROM ekbe INTO (it_with_item-ebeln,it_with_item-gjahr1,it_with_item-belnr1)
      WHERE gjahr = it_with_item-awkey+10(4) AND belnr = it_with_item-awkey(10).
      MODIFY it_with_item TRANSPORTING:ebeln.
    ELSE.
      READ TABLE it_bsik WITH KEY bukrs = it_with_item-bukrs belnr = it_with_item-belnr gjahr = it_with_item-gjahr.
      IF sy-subrc = 0.
        it_with_item-ebeln it_bsik-ebeln.
        it_with_item-zuonr it_bsik-zuonr.
        MODIFY it_with_item TRANSPORTING:ebeln,zuonr.
      ENDIF.
    ENDIF.

Now both ebeln's will be displayed under one column.

Regards

Kalpana

8 REPLIES 8

Former Member
0 Kudos

Hi Kalpana,

Use concatenate to merge them with conversion exit alpha input before concatenating

output field should be char 20.

0 Kudos

Hi Mohammed,

Could you please elaborate with an example.

FredericGirod
Active Contributor
0 Kudos

Hi Kalpana,

if you need to put directly the data using the SELECT statement, you could specify only the structure, not each field. For that, you need to have the fields in the begin of the structure, in the correct order ...

if you need to put it in a table, as Mohammed said, you made a loop, and make a concatenate to merge the two field in one.

concatenate ebeln1 ebeln2 into ebeln.

regards

Fred

venkateswaran_k
Active Contributor
0 Kudos

Hi Kalpana

In your it_table  (internal table) where you store the resultant data, you need to add one more column with length of 25.

Then based on your code, 

READ TABLE it_bsik WITH KEY bukrs = it_with_item-bukrs belnr = it_with_item-belnr gjahr = it_with_item-gjahr.

    IF sy-subrc = 0.

      it_with_item-ebeln it_bsik-ebeln.

      it_with_item-zuonr it_bsik-zuonr.

      CONCATENATE  it_bsik-ebeln it_with_item-ebeln INTO it_with_item-your_new_field

         SEPARATED BY '-'.

      MODIFY it_with_item TRANSPORTING: it_with_item-your_new_field.

    ENDIF.

Regards,

Venkat

0 Kudos

Hi venkateswaran,

I want fields row by row in a column.

According to u, it stores data side by side i.e., in a same row.

0 Kudos

Maybe clarify your question ...

loop at itab_data where ebeln2 ne space.

move itab_data-ebeln2 to is_Data-ebeln1.

append is_data to itab_data.

endloop.

former_member184958
Active Participant
0 Kudos

Hi Kalpana,

TYPES: BEGIN OF ty_ekbe,
         ebeln TYPE ekbe-ebeln,
         ebelp TYPE ekbe-ebelp,
       END OF ty_ekbe,

       BEGIN OF ty_bsik,
          bukrs TYPE bsik-bukrs,
         ebeln TYPE bsik-ebeln,
       END OF ty_bsik,

       BEGIN OF ty_ekbe1,
         ebeln(20) TYPE c,
         ebelp TYPE ekbe-ebelp,
         bukrs TYPE bsik-bukrs,
       END OF ty_ekbe1.

DATA: it_ekbe TYPE STANDARD TABLE OF ty_ekbe,
       it_bsik TYPE STANDARD TABLE OF ty_bsik,
       it_ekbe1 TYPE STANDARD TABLE OF ty_ekbe1,

       wa_ekbe TYPE ty_ekbe,
       wa_ekbe1 TYPE ty_ekbe1,
       wa_bsik TYPE ty_bsik,

       lv_idx TYPE sy-index.


wa_ekbe-ebeln = '4500017330'.
wa_ekbe-ebelp = '00010'.
APPEND wa_ekbe to it_ekbe.

wa_ekbe-ebeln = '4500017331'.
wa_ekbe-ebelp = '00020'.
APPEND wa_ekbe to it_ekbe.

wa_bsik-bukrs = '100'.
wa_bsik-ebeln = '4500017332'.
APPEND wa_bsik to it_bsik.

wa_bsik-bukrs = '100'.
wa_bsik-ebeln = '4500017333'.
APPEND wa_bsik to it_bsik.

LOOP AT it_ekbe INTO wa_ekbe.
if wa_ekbe is  not INITIAL.
   lv_idx = sy-tabix.
READ TABLE it_bsik INTO wa_bsik INDEX lv_idx.

CONCATENATE wa_ekbe-ebeln wa_bsik-ebeln INTO wa_ekbe1-ebeln SEPARATED BY space.
wa_ekbe1-ebelp = wa_ekbe-ebelp.
wa_ekbe1-bukrs = wa_bsik-bukrs.
APPEND wa_ekbe1 to it_ekbe1.
CLEAR lv_idx.
ENDIF.
ENDLOOP.

If suppose both internal table have the same ebeln number the you just use with key instead of index.

Hope this will helpful to you.

Thank You.


Former Member
0 Kudos

Hi,

I solved my problem using If.. else condition.

IF it_with_item-blart EQ 'RE'.
      SELECT SINGLE ebeln gjahr belnr
         FROM ekbe INTO (it_with_item-ebeln,it_with_item-gjahr1,it_with_item-belnr1)
      WHERE gjahr = it_with_item-awkey+10(4) AND belnr = it_with_item-awkey(10).
      MODIFY it_with_item TRANSPORTING:ebeln.
    ELSE.
      READ TABLE it_bsik WITH KEY bukrs = it_with_item-bukrs belnr = it_with_item-belnr gjahr = it_with_item-gjahr.
      IF sy-subrc = 0.
        it_with_item-ebeln it_bsik-ebeln.
        it_with_item-zuonr it_bsik-zuonr.
        MODIFY it_with_item TRANSPORTING:ebeln,zuonr.
      ENDIF.
    ENDIF.

Now both ebeln's will be displayed under one column.

Regards

Kalpana