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

APPEND VALUES TO A TABLE

Former Member
0 Likes
6,904

Hello,

Ive declared a new local variable like this in my program:

ZIAUSWG TYPE MGAUSWG

I want to append values to this structure/Table:

First row 01

second row 20

How can append values to this kind of structures.

KInd regards

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,147

Hi,

Try like this


ZIAUSWG TYPE TABLE OF  MGAUSWG with header line .

ZIAUSWG-field1 = '10'.
append ZIAUSWG.
clear ZIAUSWG.

ZIAUSWG-field1 = '20'.
append ZIAUSWG.
clear ZIAUSWG.

loop at ZIAUSWG.
write: ZIAUSWG-field1.
endloop.

Regards,

Vikranth

13 REPLIES 13
Read only

Former Member
0 Likes
3,147

Hello David

I am not able to understand the question. Just tell me MGAUSWG is a table type or data element?

Regards

Anand.

Read only

0 Likes
3,147

Hello,

Is a table:

WLCL_ZIAUSWG TYPE MGAUSWG.

The original is IAUSWG TYPE MGAUSWG.

This table contains the screens from material master, I just want to know how to append values to this table in a program.

IAUSWG-ROW1 = 01

IAUSWG-ROW2 = 02

IAUSWG-ROW3 = 03

Kind Regards.

Read only

0 Likes
3,147

Hello David

Try in the following way.

DATA: WA_MGAUSWG LIKE LINE OF MGAUSWG.

WA_MGAUSWG = '01'.

APPEND WA_MGAUSWG TO IAUSWG.

WA_MGAUSWG = '02'.

APPEND WA_MGAUSWG TO IAUSWG.

WA_MGAUSWG = '03'.

APPEND WA_MGAUSWG TO IAUSWG.

Best regards

[How2SAP.com|http://www.how2sap.com/blog/alv/multi-line-alv-using-row_pos-in-field-catalog/]

Read only

0 Likes
3,147

Hello,

How can I create an Internal table that I can use to add my values and then assign it to my ZIAWUG variable?

Kind Regards

Read only

Former Member
0 Likes
3,148

Hi,

Try like this


ZIAUSWG TYPE TABLE OF  MGAUSWG with header line .

ZIAUSWG-field1 = '10'.
append ZIAUSWG.
clear ZIAUSWG.

ZIAUSWG-field1 = '20'.
append ZIAUSWG.
clear ZIAUSWG.

loop at ZIAUSWG.
write: ZIAUSWG-field1.
endloop.

Regards,

Vikranth

Read only

0 Likes
3,147

Hello,

In the case of this proposal, the compailer says : Tables with headers are no longer supported in the OO context.

Kind Regards

Read only

0 Likes
3,147

Hello David

Follow the following steps:

DATA: ZIAUSWG TYPE STANDARD TABLE OF MGAUSWG,

WA_MGAUSWG TYPE MGAUSWG.

WA_MGAUSWG-field1 = '10'.

append WA_MGAUSWG TO ZIAUSWG.

WA_MGAUSWG-field1 = '20'.

append WA_MGAUSWG TO ZIAUSWG.

WA_MGAUSWG-field1 = '30'.

append WA_MGAUSWG TO ZIAUSWG.

Check it. This should work.

Cheers

Anand

[How2SAP.com|http://www.how2sap.com/blog/sap-abap/persisting-setget-parameter-values-in-user-profile/]

Read only

0 Likes
3,147

Hello,

Yes, this in fact works like a charm, only a final question, how I can assign this structure to my other variable:

DATA: ZIAUSWG TYPE MGAUSWG.

DATA: ZZIAUSWG TYPE STANDARD TABLE OF MGAUSWG,

WA_MGAUSWG TYPE MGAUSWG.

WA_MGAUSWG-AUSWG = '10'.

append WA_MGAUSWG TO ZZIAUSWG.

WA_MGAUSWG-AUSWG = '20'.

append WA_MGAUSWG TO ZZIAUSWG.

WA_MGAUSWG-AUSWG = '30'.

append WA_MGAUSWG TO ZZIAUSWG.

How can I assign ZZIAUSWG. to ZIAUSWG

Kind Regards

Read only

0 Likes
3,147

This is what I got.

I want to Assign:

ZZIAUSWG Standard Table[16x1(4)]

To:

ZIAUSWG Structure: flat & charlike

Kind Regards

Read only

0 Likes
3,147

Structures cannot hold any records like tables do. They can only be used for reference structures in the programs. They hold values only during the execution of the program i,e runtime . Declare a internal table of the type of the structure and assign.

Read only

Former Member
0 Likes
3,147

Hi David,

You need to first decide which field of the table is to be populated.

Then take help on APPEND by pressing f1 on the same.

Populate the field with desired value in workarea and append the same to internal table.

Hope its help you.

Read only

Clemenss
Active Contributor
0 Likes
3,147

Hi David,

possibly you haven't got too much ABAP training. A book could help you.

Before getting too many too confusing answers here in the forum, it is always worth to use

[SAP online help - it is free!|http://help.sap.com/]

as a primary source.

For you, [Internal Tables, Creating Internal Tables, Processing Internal Tables|http://help.sap.com/saphelp_NW70EHP1/helpdata/en/c9/5472f6787f11d194c90000e8353423/frameset.htm] may be helpful.

Kind regards,

Clemens

Read only

Former Member
0 Likes
3,147

Hello,

I just wanted to say that my problem was solved, Im a JAVA programmer and Im really used to a different way of using objects.

Thanks to those how made a constructive response.

This what the final result:

INTERFACE METHOD:

@78\QImporting@ ZIRMMG1 TYPE RMMG1 Mat. Master Maintenance: Initial Parameters - Orig. Material

@79\QExporting@ ZIAUSWG_RET TYPE STANDARD TABLE Material Maintenance: Selected Screens

method ZINTF_ASSIGN_VIEWS~ASSIGNPLANTVIEWS.

WRITE:/5 'MATERIAL RECIEVED' COLOR 5 INTENSIFIED,

35 'PLANT RECIEVED' COLOR 5 INTENSIFIED.

SKIP.

WRITE:/5 ZIRMMG1-MATNR,

35 ZIRMMG1-WERKS.

SKIP.

DATA: ZZIAUSWG TYPE STANDARD TABLE OF MGAUSWG,

WA_MGAUSWG TYPE MGAUSWG.

WA_MGAUSWG-AUSWG = '07'.

append WA_MGAUSWG TO ZZIAUSWG.

WA_MGAUSWG-AUSWG = '08'.

append WA_MGAUSWG TO ZZIAUSWG.

WA_MGAUSWG-AUSWG = '09'.

ZIAUSWG_RET = ZZIAUSWG.

endmethod.