Application Development and Automation 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: 
Read only

How append field to table?

Former Member
0 Likes
1,322

Hello all.

Have.

DATA  wa_table TYPE TABLE OF mytable  WITH HEADER LINE.

need appnd field to wa_table in abap.

how?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,262

hi..

append wa_itab to itab.

in your case u have created internal table of name wa_table.

so ..

append wa_table.

10 REPLIES 10
Read only

former_member189059
Active Contributor
0 Likes
1,262
wa_table-field = 'some value'.
append wa_table.
Read only

Former Member
0 Likes
1,263

hi..

append wa_itab to itab.

in your case u have created internal table of name wa_table.

so ..

append wa_table.

Read only

Former Member
0 Likes
1,262

Hi,

i think you want to add an extra field to the table wa_table.

this is not possible

but we can append the records only..

as you have already declared the structure of the internal table

you cannot change after declaring

reward points if helpful,

thanks & regards,

venkatesh

Read only

Former Member
0 Likes
1,262

ok..

how add field to structure of wa_table?

in abap

Read only

0 Likes
1,262

Hi.. plz check this code :

TYPES: BEGIN OF ty_ab,

include TYPE p0001,

fld1(10) TYPE c,

END OF ty_ab.

DATA: wa TYPE ty_ab.

Reward for useful answer

Regards

Pradeep

Read only

Former Member
0 Likes
1,262

Hi Andrey,

A better way to do this is to create an internal table and work area separately:

Data : it_tab type table of mytable, * this creates internal table of type mytab

wa_tab type mytable. * Create a workarea of type mytab.

  • assign values to the workarea and modify the internal table using the workarea

wa_tab-field1 = 'xyz'.

wa_tab-field2 = 'abc'.

append wa_tab to it_tab.

Regards,

Sonal

<b>Reward points if helpful</b>

Read only

Former Member
0 Likes
1,262

HI,

try this,

types: begin of t_itab.

include structure your structue.

types:

(you can include the extra fields likthis)

field1 type some dataelement

field2 type some data element 2

...

..

.

end of t_itab.

data: wa_table type standard table of t_itab.

like this you can add as many number of fields as you want

this is possible only while declaring the table

after that it will be freezed and you can not do any changes to the itab

reward points if helpful,

thanks & regards,

venkatesh

Read only

Former Member
0 Likes
1,262

see the full code how the data is select into work area and then to your internal table .

"first example

TYPES: BEGIN OF t_bseg,
*include structure bseg.
  bukrs     LIKE bseg-bukrs,
  belnr     LIKE bseg-belnr,
  gjahr     LIKE bseg-gjahr,
  buzei     LIKE bseg-buzei,
  mwskz     LIKE bseg-mwskz,         "Tax code
  umsks     LIKE bseg-umsks,         "Special G/L transaction type
  prctr     LIKE bseg-prctr,         "Profit Centre
  hkont     LIKE bseg-hkont,         "G/L account
  xauto     LIKE bseg-xauto,
  koart     LIKE bseg-koart,
  dmbtr     LIKE bseg-dmbtr,
  mwart     LIKE bseg-mwart,
  hwbas     LIKE bseg-hwbas,
  aufnr     LIKE bseg-aufnr,
  projk     LIKE bseg-projk,
  shkzg     LIKE bseg-shkzg,
  kokrs     LIKE bseg-kokrs,
 END OF t_bseg.
DATA: it_bseg TYPE STANDARD TABLE OF t_bseg INITIAL SIZE 0,
      wa_bseg TYPE t_bseg.

SELECT bukrs belnr gjahr buzei mwskz umsks prctr hkont xauto koart
       dmbtr mwart hwbas aufnr projk shkzg kokrs
  FROM bseg
  INTO wa_bseg.

  APPEND wa_bseg TO it_bseg.
ENDSELECT.

"second example :


  DATA  : lt_bsik      TYPE  TABLE OF txi_bsik ,
          ls_bsik      LIKE  LINE OF  lt_bsik.

  DATA : ld_cursor   TYPE cursor.

OPEN CURSOR ld_cursor  FOR
      SELECT * FROM bsak
        WHERE budat LE ls_butab-keydt
        AND   augdt GT ls_butab-keydt
        AND   bukrs  = ls_butab-bukrs.


    DO.
      FETCH NEXT CURSOR ld_cursor
            INTO CORRESPONDING FIELDS OF TABLE lt_bsik
            PACKAGE SIZE txilm_package_size.
      IF sy-subrc NE 0.
        CLOSE CURSOR ld_cursor.
        EXIT.
      ENDIF.

      SORT lt_bsik BY bukrs gjahr belnr.
      LOOP AT lt_bsik INTO ls_bsik.
"if change   in ls_bsik   move to lt_bsik .
        MODIFY lt_bsik FROM ls_bsik.
      ENDLOOP.

 ENDDO.

reward points if it is usefull...

Girish

Read only

Former Member
0 Likes
1,262

Hi Andrey,

can you please show why you want do do this?

Perhaps there is another way.

Regards, Dieter

Read only

Former Member
0 Likes
1,262

Hi,

U want to append a field to that table.

It is possible thru creating a new type containing the wa_table structure and a requied filed. Then declre table using the new type.

Example:

TYPES:BEGIN OF TY_MYTABLE.

INCLUDE STRUCTURE <STRUCTURE OF MYTABLE>.

TYPES: <NEW FIELD1> TYPE <TYPE>.

TYPES:END OF TY_MYTABLE.

Now declare ur table:

DATA wa_table TYPE TABLE OF ty_mytable WITH HEADER LINE.

This can be useful when u need to add another field in that table in future.

Reward points if helpful,

Regards,

Rajesh