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

help to abap code declaration

Former Member
0 Likes
1,132

Hi expert,

I have this code:

DATA: t_appo TYPE STANDARD TABLE OF /bic/cszbw_delpack
                               INITIAL SIZE 0.
    DATA: wa_idx  TYPE i.
    DATA: wa_source LIKE LINE OF SOURCE_PACKAGE.

    LOOP AT SOURCE_PACKAGE INTO wa_source.
      wa_idx = sy-tabix.

      READ TABLE t_appo TRANSPORTING NO FIELDS
            WITH KEY /bic/zc_collo = wa_source-numcl.

      IF sy-subrc = 0.
        wa_source-brwei = 0.
        MODIFY SOURCE_PACKAGE FROM wa_source
                             INDEX wa_idx
                      transporting brwei.

      ELSE.


      ENDIF.
    ENDLOOP.

after ELSE, I need to insert the wa_source value into t_appo.

How can I do?

May be t_appo is bad declared.

Consider that t_appo cannot have an header line otherwise I'll have an error as

"E:Tables with headers are no longer supported in the OO context."

than, in any loop, t_appo table has to popolated with an record.

because I have to keep in memory all processed records.

Help me please asap?

thank you so much.

1 ACCEPTED SOLUTION
Read only

VXLozano
Active Contributor
0 Likes
1,035

In your case, you need to declare something like:

DATA: w_appo TYPE /bic/cszbw_delpack

And move data from wa_source to w_appo, and use the "APPEND w_appo TO t_appo." I said you in my first post.

9 REPLIES 9
Read only

Former Member
0 Likes
1,035

Hello,

Try something like this,


DATA: t_appo TYPE STANDARD TABLE OF /bic/cszbw_delpack with header line. 
    DATA: wa_idx  TYPE i.
    DATA: wa_source LIKE LINE OF SOURCE_PACKAGE.
 
    LOOP AT SOURCE_PACKAGE INTO wa_source.
      wa_idx = sy-tabix.
 
      READ TABLE t_appo TRANSPORTING NO FIELDS
            WITH KEY /bic/zc_collo = wa_source-numcl.
 
      IF sy-subrc = 0.
        wa_source-brwei = 0.
        MODIFY SOURCE_PACKAGE FROM wa_source
                             INDEX wa_idx
                      transporting brwei.
      ELSE.
    move-corresponding wa_source to t_appo.
    append t_appo.
      ENDIF.
    ENDLOOP.

Vikranth

Read only

0 Likes
1,035

thanks for your reply,

but t_appo is not an internal table with header line!

As my details, the system do not admitted tables with header line.

Read only

0 Likes
1,035

And because this, you must define a "parallel" workarea for your table. The workarea OO doesn't like is the one created using "WITH HEADER LINE" or "OCCURS n".

Read only

0 Likes
1,035

Am sorry i dint read your question properly. You could try the suggestion given by Vicenç Lozano

Read only

0 Likes
1,035

Thanks Vicenç,

I ask you other suggestion.

How can I declared an internal table with only one field and without header line?

Read only

0 Likes
1,035

It's an easy question:

Table:

DATA: t_table TYPE TABLE OF type_name.

Workarea:

DATA: w_table TYPE type_name.

Both, using non defined types (data elements/dominions not in SE11)

TYPE: BEGIN OF my_type,
        field1 TYPE type_field_1,
        ...
        fieldn TYPE type_field_n,
      END OF my_type.

DATA: t_table TYPE TABLE OF my_type, "table
      w_table TYPE my_type. "workarea

(the field list of my_type can have a single field)

Edited by: Vicenç Lozano on Dec 23, 2009 3:09 PM

Read only

VXLozano
Active Contributor
0 Likes
1,035

Define a workarea (header line) for your internal table

DATA: w_appo TYPE the_same_type_than_your_table.

And use an APPEND.

APPEND w_appo TO t_appo.

Read only

VXLozano
Active Contributor
0 Likes
1,036

In your case, you need to declare something like:

DATA: w_appo TYPE /bic/cszbw_delpack

And move data from wa_source to w_appo, and use the "APPEND w_appo TO t_appo." I said you in my first post.

Read only

Former Member
0 Likes
1,035

that's clear!!

thank you Vicenç