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: 

3 items into 1 records

Former Member
0 Kudos

Hi to averybody

I'm using the table konm into my table ITAB.

The filed key is knumh.

My question is it possibile to have all into 1 records?

I tried with didn't work

CASE konm-klfn1.

WHEN 1.

clear itab

append

WHEN 2

clear itab

append

ECC

ECC

***********************************************

TABLE KONM

knumh klfn1 QT Value

0000034937 0001 1,000 40,00

0000034937 0002 0,965 250,00

0000034937 0003 0,822 500,0

************************************************

I would have

TABLE ITAB

knumh QTA1 VAL1 QTA2 VAL2 QTA3 VAL3

0000034937 1,000 40,00 0,965 250,00 0,822 500,00

Thanks a lot and good works

5 REPLIES 5

Former Member
0 Kudos

You could use dynamic internal table.

Former Member
0 Kudos

thanks Alvaro for your replay

but What is dynamic internal table?

0 Kudos

Is an internal table which you create in the execution of the program.

See this link there is a good program that create Internal Table

https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/dynamic%252binternal%252btable

Former Member
0 Kudos

Check this code and see if it's what you are looking for.


DATA: BEGIN OF wa_konm,
knumh(10),
klfn(4),
qt(5) TYPE p DECIMALS 3,
value(6) TYPE p DECIMALS 2,
END OF wa_konm,

it_konm LIKE STANDARD TABLE OF wa_konm,


BEGIN OF wa_itab,
knumh(10),
qta1(5) TYPE p DECIMALS 3,
val1(6) TYPE p DECIMALS 2,
qta2(5) TYPE p DECIMALS 3,
val2(6) TYPE p DECIMALS 2,
qta3(5) TYPE p DECIMALS 3,
val3(6) TYPE p DECIMALS 2,
END OF wa_itab,

itab LIKE STANDARD TABLE OF wa_itab.

INITIALIZATION.

  wa_konm-knumh = '0000034937'.
  wa_konm-klfn = '0001'.
  wa_konm-qt = '1.000'.
  wa_konm-value = '40.00'.
  APPEND wa_konm TO it_konm.
  wa_konm-knumh = '0000034937'.
  wa_konm-klfn = '0002'.
  wa_konm-qt = '0.965'.
  wa_konm-value = '250.00'.
  APPEND wa_konm TO it_konm.
  wa_konm-knumh = '0000034937'.
  wa_konm-klfn = '0003'.
  wa_konm-qt = '0.822'.
  wa_konm-value = '500.00'.
  APPEND wa_konm TO it_konm.
  wa_konm-knumh = '0000034938'.
  wa_konm-klfn = '0001'.
  wa_konm-qt = '0.722'.
  wa_konm-value = '400.00'.
  APPEND wa_konm TO it_konm.
  wa_konm-knumh = '0000034938'.
  wa_konm-klfn = '0002'.
  wa_konm-qt = '0.922'.
  wa_konm-value = '600.00'.
  APPEND wa_konm TO it_konm.

START-OF-SELECTION.

  LOOP AT it_konm INTO wa_konm.
    wa_itab-knumh = wa_konm-knumh.
    CASE wa_konm-klfn.
      WHEN '0001'.
        wa_itab-qta1 = wa_konm-qt.
        wa_itab-val1 = wa_konm-value.
      WHEN '0002'.
        wa_itab-qta2 = wa_konm-qt.
        wa_itab-val2 = wa_konm-value.
      WHEN '0003'.
        wa_itab-qta3 = wa_konm-qt.
        wa_itab-val3 = wa_konm-value.
    ENDCASE.
    AT END OF knumh.
      APPEND wa_itab TO itab.
      clear wa_itab.
    ENDAT.
  ENDLOOP.

  LOOP AT itab INTO wa_itab.
    WRITE:/, wa_itab-knumh , wa_itab-qta1 , wa_itab-val1, wa_itab-qta2
    , wa_itab-val2 , wa_itab-qta3 , wa_itab-val3.
  ENDLOOP.

Former Member
0 Kudos

Thanks to everybody for your support

Thanks Gustavo, your replay has worked out my problem