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: 

MODIFY TABLE <itab> FROM <wa> [TRANSPORTING <f1> <f 2> ...].

Former Member
0 Kudos

Hi Freinds,

I know about Modify Table, but what is Transporting and what is the need of this Transporting, Can any Expain me the concept and give simple program using Transport

Thanks and Regards

Srini

6 REPLIES 6

Former Member
0 Kudos

Hi,

... TRANSPORTING comp1 comp2 ...

Effect

The TRANSPORTING addition has the effect that only the specified comp1 comp2 ... components of the work area are assigned to the corresponding components of the line(s) to be changed. For sorted tables and hashed tables, no table key components may be specified after TRANSPORTING.

The comp1 comp2 ... component specifications are made in accordance with the rules specified in Component specification, with the constraint that after TRANSPORTING, no attributes of classes can be addressed using the object component selector.

Example.



PARAMETERS p_carrid TYPE scarr-carrid. 

DATA scarr_tab TYPE SORTED TABLE OF scarr 
               WITH UNIQUE KEY carrid. 

DATA: idx      TYPE sy-tabix, 
      scarr_wa TYPE scarr. 

SELECT * 
       FROM scarr 
       INTO TABLE scarr_tab. 

READ TABLE scarr_tab 
     WITH TABLE KEY carrid   = p_carrid 
     TRANSPORTING NO FIELDS. 

idx = sy-tabix. 

scarr_wa-currcode = 'EUR'. 

MODIFY scarr_tab INDEX idx FROM scarr_wa 
       TRANSPORTING currcode. 

... itab FROM wa TRANSPORTING comp1 comp2 ... WHERE log_exp.

Effect

With these additions the MODIFY statement assigns the content of the comp1 comp2 ... components of the wa work area specified after TRANSPORTING to all lines in the itab table that meet the logical condition log_exp. The wa work area must be compatible with the line type of the internal table.

The TRANSPORTING addition has the same effect as changing individual lines. The WHERE addition can only be specified together with the TRANSPORTING addition. After WHERE, any logical expression can be specified in which the first operand of each individual comparison is a component of the internal table. All logical expressions are therefore possible, with the exception of IS ASSIGNED, , and IS SUPPLIED. It is not possible to dynamically specify a component using bracketed character-type data objects.

Note

While for standard tables all lines in the internal table are checked for the logical expression of the WHERE addition, optimized access can be achieved for sorted tables and (as of Release 7.0) hashed tables by checking at least an initial part of the table key, in the case of sorted tables, or the entire table key, in the case of hashed tables, for AND-linked equality queries in the logical expression. The optimization also works if the logical expression contains further AND-linked queries with any operator.

Example.



PARAMETERS: p_carrid TYPE sflight-carrid, 
            p_connid TYPE sflight-connid, 
            p_plane1 TYPE sflight-planetype, 
            p_plane2 TYPE sflight-planetype. 

DATA sflight_tab TYPE SORTED TABLE OF sflight 
                 WITH UNIQUE KEY carrid connid fldate. 

DATA sflight_wa TYPE sflight. 

SELECT * 
       FROM sflight 
       INTO TABLE sflight_tab 
       WHERE carrid = p_carrid AND 
             connid = p_connid. 

sflight_wa-planetype = p_plane2. 

MODIFY sflight_tab FROM sflight_wa 
       TRANSPORTING planetype WHERE planetype = p_plane1. 

Hope it will helps

nisha_vinod
Advisor
Advisor
0 Kudos

Hello Srinivas

Consider the following eg where I would try to describe 1 use-case for MODIFY TABLE from wa transporting fields...

There is a work area ls_addr defined as follows:

DATA : BEGIN OF ls_addr,

ls_street type string,

ls_hnum type i

END OF ls_addr.

DATA : lt_adr like table of ls_addr.

<<Logic>>

append ls_addr to lt_addr.

<<Based on some condition in your logic, say ls_street alone is modified for ls_hnum = '123' >>

Then you now want to modify the record in lt_addr with the new ls_street. You could use:

MODIFY TABLE lt_addr from ls_addr transporting ls_street where ls_hnum = '123'.

When the internal table is modified, only the field(s) following 'transporting' get modified. The other fields remain unaffected.

Hope this example helps.

Regards

Nisha

Edited by: Nisha NC on Sep 24, 2008 7:22 AM

gopi_narendra
Active Contributor
0 Kudos

TRANSPORTING tells that only specific fields will be modified which are given after the TRANSPORTING clause.

For ex: modify it_tab from is_tab transporting <field1>.

where it_tab is the internal table, is_tab is the work area

and <field1> is the field that is being modified from work area into the internal table it_tab.

Hope this clarifies.

Regards

Gopi

Former Member
0 Kudos

Simple program for transporting

Data: begin of itab occurs 0,

c1,

c2 type i,

end of itab.

itab-c1 = 'a'.

itab-c2 = 10.

collect itab.

itab-c1 = 'b'.

itab-c2 = 10.

collect itab.

itab-c1 = 'X'.

modify itab transporting c1 where c1 = 'a'.

loop at itab.

write:/ itab-c1,

itab-c2.

endloop.

Hope this program will give you clear picture

Former Member
0 Kudos

Hi,

Syntax :

... {TABLE itab}|{itab INDEX idx} FROM wa

[TRANSPORTING comp1 comp2 ... ]

With these additions, the MODIFY statement assigns a line specified by itab_line to the content of the wa work area. The line can be specified using the table key or the table index. For the variant with the TABLE addition, the line is specified using the table key. For the variant with the INDEX addition, it is specified using the table index. The latter is only possible for index tables.

TRANSPORTING can be used to restrict the comp components to be modified. result can be used when you change an individual line after Release 6.10 to set a reference in the form of a field symbol or a data reference to the changed line.

In the case of access using the table key, index access to sorted tables and when the TRANSPORTING addition is used, the wa work area must be compatible with the line type of the internal table. Only in the case of insertion using the table index in standard tables without the TRANSPORTING addition can wa be incompatible with the line type of the internal table, and is converted to the line type according to the conversion rules.

The TRANSPORTING addition has the effect that only the specified comp1 comp2 ... components of the work area are assigned to the corresponding components of the line(s) to be changed. For sorted tables and hashed tables, no table key components may be specified after TRANSPORTING.

The comp1 comp2 ... component specifications are made in accordance with the rules specified in Component specification, with the constraint that after TRANSPORTING, no attributes of classes can be addressed using the object component selector.

Former Member
0 Kudos

Hi srini,

Following program Changes the contents of the planetype component for all lines in the sflight_tab internal table in which this component contains the value p_plane1 to the value p_plane2.

PARAMETERS: p_carrid TYPE sflight-carrid,

p_connid TYPE sflight-connid,

p_plane1 TYPE sflight-planetype,

p_plane2 TYPE sflight-planetype.

DATA sflight_tab TYPE SORTED TABLE OF sflight

WITH UNIQUE KEY carrid connid fldate.

DATA sflight_wa TYPE sflight.

SELECT *

FROM sflight

INTO TABLE sflight_tab

WHERE carrid = p_carrid AND

connid = p_connid.

sflight_wa-planetype = p_plane2.

MODIFY sflight_tab FROM sflight_wa

TRANSPORTING planetype WHERE planetype = p_plane1.

Thanks,

Naveen kumar.