Skip to Content
avatar image
Former Member

Move data accross Internal table and structure

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Nov 15, 2007 at 06:13 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 15, 2007 at 06:14 AM

    Hi,

    Just assign individual field like below

    wa_addr-name1 = I_addr-name1

    Regards,

    Atish

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 15, 2007 at 06:15 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 15, 2007 at 06:22 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded