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

Move data accross Internal table and structure

Former Member
0 Likes
3,358

Types : BEGIN OF tt_addr,

name1 TYPE t001w-name1,

lgort TYPE ekpo-lgort,

name2 TYPE adrc-name1,

city1 TYPE adrc-city1,

street TYPE adrc-street,

region TYPE adrc-region,

lfdat TYPE likp-lfdat,

END OF tt_addr.

Data : i_addr TYPE STANDARD TABLE OF tt_addr initial size 0.

Data : wa_addr TYPE ADRC.

I have internal table 'i_addr' of 'tt_addr '. "Contains 6 Fields

And a structure wa_addr of type ADRC. " Contains 4 Fields

I have only one line data in I_addr (6 Fields), I have to move (4 Fields of 6 Fields) to wa_addr .

So how do i do it.........Give sample code or idea or syntax

Thanks In Advance.

ll give points if useful.

Types : BEGIN OF tt_addr,

name1 TYPE t001w-name1,

lgort TYPE ekpo-lgort,

name2 TYPE adrc-name1,

city1 TYPE adrc-city1,

street TYPE adrc-street,

region TYPE adrc-region,

lfdat TYPE likp-lfdat,

END OF tt_addr.

Data : i_addr TYPE STANDARD TABLE OF tt_addr initial size 0.

Data : wa_addr TYPE ADRC.

I have internal table 'i_addr' of 'tt_addr '. "Contains 6 Fields

And a structure wa_addr of type ADRC. " Contains 4 Fields

I have only one line data in I_addr (6 Fields), I have to move (4 Fields of 6 Fields) to wa_addr .

So how do i do it.........Give sample code or idea or syntax

Thanks In Advance.

ll give points if useful.

4 REPLIES 4
Read only

former_member386202
Active Contributor
0 Likes
1,350

Hi,

Using loop u can pass that value, but structure contains only one record at a time.

refer this code.

SORT it_pa0001 BY pernr.

IF NOT it_final[] IS INITIAL.

LOOP AT it_final INTO wa_final.

lv_index = sy-tabix.

*--Clear

CLEAR : wa_pa0001.

READ TABLE it_pa0001 INTO wa_pa0001 WITH KEY pernr = wa_final-pernr

BINARY SEARCH.

IF sy-subrc EQ 0.

wa_final-ename = wa_pa0001-ename.

ENDIF.

MODIFY it_final FROM wa_final INDEX lv_index

TRANSPORTING ename.

*--Clear

CLEAR : wa_pa0001,

wa_final.

ENDLOOP.

ENDIF.

Regards,

Prashant

Read only

Former Member
0 Likes
1,350

Hi,

Just assign individual field like below

wa_addr-name1 = I_addr-name1

Regards,

Atish

Read only

Former Member
0 Likes
1,350

structure maintain only one record.

loop at itab into wa.

wa-field-wa1 = "wefewf".

wa-field-wa13 i= "wefewf"

wa-field-wa1 = "wefewf"

wa-field-wa14 = "wefewf"

append wa to itab2.

enloop.

Read only

Former Member
0 Likes
1,350

HI

see this small code

where i am moving data from internal table work area to final internal table worksrea and then appending it to internal table

LOOP AT IT_SOBID INTO WA_SOBID." where otype eq s_otype and objid eq s_objid.

    READ TABLE IT_HRP1026 WITH KEY OBJID = WA_SOBID-SOBID OTYPE = WA_SOBID-SCLAS INTO WA_HRP1026.
    IF SY-SUBRC EQ 0.
      READ TABLE IT_HRP1000 WITH KEY OBJID = WA_SOBID-SOBID INTO WA_HRP1000.


      WA_OUTPUT-OBJID = WA_HRP1026-OBJID.
      WA_OUTPUT-BEGDA = WA_SOBID-BEGDA.
      WA_OUTPUT-ENDDA = WA_SOBID-ENDDA.
      WA_OUTPUT-AEDTM = WA_HRP1026-AEDTM.
      WA_OUTPUT-UNAME = WA_HRP1026-UNAME.
      WA_OUTPUT-STEXT = WA_HRP1000-STEXT.


      READ TABLE IT_REASON WITH KEY CANCR = WA_HRP1026-CANCR INTO WA_REASON.


      WA_OUTPUT-CANCRT = WA_REASON-CANCRT.
      CLEAR WA_REASON-CANCRT.

      READ TABLE IT_LOCATION1 WITH KEY OBJID = WA_HRP1026-OBJID INTO WA_LOCATION1..

      READ TABLE IT_LSTEXT WITH KEY OBJID = WA_LOCATION1-SOBID OTYPE = 'F' INTO WA_LSTEXT.

             WA_OUTPUT-LSTEXT = WA_LSTEXT-LSTEXT.
             CLEAR WA_LSTEXT-LSTEXT.


      APPEND WA_OUTPUT TO IT_OUTPUT.
      CLEAR WA_OUTPUT.
      CLEAR WA_OUTPUT-CANCRT.
    ENDIF.
  ENDLOOP.