Read statement from 2 different internal table.

Hello,
I am new to ABAP and try to work out these statements. Please can someone help me in correcting the code.
Requirement is
1. I have Sales Header Table
2. Sales Item Table.
Both the above table has Doc_number as the key filed and both has CREATEDON date . While reading the Data from SALES ITem table i have copy the CREATEON Date from SAles Header Table.
For the above requirment i have used the following code which is going for unending loop.
Tables: /BIC/ASALHDR0100,/BIC/ASALORD0100.
DATA: CHDATE like /BIC/ASALHDR0100 occurs 0 with header line,
      WA_CHDATE type /BIC/ASALHDR0100,
      CiDATE like /BIC/ASALORD0100 occurs 0 with header line,
      WA_CiDATE type /BIC/ASALORd0100.
      SELECT * from /BIC/ASALORD0100 into table CIDATE.
      select * from /BIC/ASALHDR0100 into CHDATE for all entries in CIDATE where DOC_NUMBER = CIDATE-DOC_NUMBER.
Append CHDATE.
      endselect.
loop at CHDATE INTO WA_CHDATE.
    LOOP at CIDATE into WA_CIDATE.
    if WA_CHDATE-DOC_NUMBER = WA_CIDATE-DOC_NUMBER.
Read table CHDATE into WA_CHDATE with KEY doc_number = WA_CIDATE-doc_number .
          write: WA_CHDATE-DOC_NUMBER,
                  WA_chdate-createdon,
                 WA_CIDATE-DOC_NUMBER.
                 ENDIF.
                 ENDLOOP.
          endloop.
Thanks
Edited by: Rob Burbank on Jul 26, 2010 9:34 AM

HI,
try thsi code.
TABLES: /bic/asalhdr0100,/bic/asalord0100.
DATA: chdate LIKE /bic/asalhdr0100 OCCURS 0 WITH HEADER LINE,
wa_chdate TYPE /bic/asalhdr0100,
cidate LIKE /bic/asalord0100 OCCURS 0 WITH HEADER LINE,
wa_cidate TYPE /bic/asalord0100.
SELECT * FROM /bic/asalord0100 INTO TABLE cidate.
SELECT * FROM /bic/asalhdr0100 INTO TABLE chdate FOR ALL ENTRIES IN cidate WHERE doc_number = cidate-doc_number.
LOOP AT chdate INTO wa_chdate.
  LOOP AT cidate INTO wa_cidate.
    IF wa_chdate-doc_number = wa_cidate-doc_number.
      READ TABLE chdate INTO wa_chdate WITH KEY doc_number = wa_cidate-doc_number .
      WRITE: wa_chdate-doc_number,
      wa_chdate-createdon,
      wa_cidate-doc_number.
    ENDIF.
  ENDLOOP.
ENDLOOP.
Regards,
Pravin

Similar Messages

  • How to join  fields from different internal tables and display into one int

    hai i have one doubt...
    how to join  fields from different internal tables and display into one internal table..
    if anybody know the ans for this qus tell me......

    hii
    you can read data as per condition and then can join in one internal table using READ and APPEND statement..refer to following code.
    SELECT bwkey                         " Valuation Area
             bukrs                         " Company Code
        FROM t001k
        INTO TABLE i_t001k
       WHERE bukrs IN s_bukrs.
      IF sy-subrc EQ 0.
        SELECT bwkey                       " Valuation Area
               werks                       " Plant
          FROM t001w
          INTO TABLE i_t001w
           FOR ALL ENTRIES IN i_t001k
         WHERE bwkey = i_t001k-bwkey
           AND werks IN s_werks.
        IF sy-subrc EQ 0.
          LOOP AT i_output INTO wa_output.
            READ TABLE i_t001w INTO wa_t001w WITH KEY werks = wa_output-werks.
            READ TABLE i_t001k INTO wa_t001k WITH KEY bwkey = wa_t001w-bwkey.
            wa_output-bukrs = wa_t001k-bukrs.
            MODIFY i_output FROM wa_output.
            CLEAR wa_output.
          ENDLOOP.                         " LOOP AT i_output
        ENDIF.                             " IF sy-subrc EQ 0
    regards
    twinkal

  • How to insert  data from different internal  table  into a data base table

    hi all,
             I want to insert a particular field in an internal table to a field in a data base table.Note that the fields in the internal table and database table are not of the same name since i need to insert data from different internal tables.can some one tell me how to do this?
    in short i want to do something like the foll:
    INSERT  INTO ZMIS_CODES-CODE VALUE '1'.
    *INSERT INTO ZMIS_CODES-COL1 VALUE DATA_MTD-AUFNR .(zmis_codes is the db table and data_mtd is the int.table)

    REPORT  ZINSERT.
    tables kna1.
    data: itab LIKE KNA1.
    data lv_kUNAG LIKE KNA1-KUNNR.
    lv_kuNAG =  '0000010223'.
    ITAB-kuNNR = lv_kuNAG.
    ITAB-name1 = 'XYZ'.
    INSERT INTO KNA1 VALUES ITAB.
    IF SY-SUBRC = 0.
    WRITE:/ 'SUCCESS'.
    ELSE.
    WRITE:/ 'FAILED'.
    ENDIF.
    Here lv_kunag is ref to kna1 kunnr passed in different name
    In internal table .
    Try and let me know if this logic dint work.

  • How to read data from an internal table into a real table?

    Hello experts,
    I'm relatively new to ABAP and I'm trying to figure out how to read data from an internal table into a table that I created.  I'm trying to use the RRW3_GET_QUERY_VIEW_DATA function module to read data from a multiprovider.  I'm trying to read data from the e_cell_data and e_axis_data tables into a table that I've already created.  Please see code below.
    TABLES MULTITAB.
    DATA:
      query_name TYPE RSZCOMPID,
      s_cubename TYPE RSINFOPROV,
      t_cell_data TYPE RRWS_T_CELL,
      t_axis_data TYPE RRWS_THX_AXIS_DATA,
      t_axis_info TYPE RRWS_THX_AXIS_INFO,
      wa_t_cell_data like line of t_cell_data,
      wa_t_axis_data like line of t_axis_data,
      w_corp_tab like line of t_cell_data.
    s_cubename = 'CORP_MPO1'.
    query_name = 'Z_corp_test'.
        CALL FUNCTION 'RRW3_GET_QUERY_VIEW_DATA'
           EXPORTING
             i_infoprovider           = s_cubename
             i_query                  = query_name
            i_t_parameter            = query_string_tab
           IMPORTING
             e_cell_data              = t_cell_data
             e_axis_data              = t_axis_data
             e_axis_info              = t_axis_info.
    If anyone has any information to help me, I would greatly appreciate it.  Thanks.

    Hi,
    <li>Once you call the function module RRW3_GET_QUERY_VIEW_DATA, lets say data is available in the corresponding tables e_cell_data e_axis_data which you have mentioned.
    <li>Modify your internal table defined for other purpose, with data from e_cell_data e_axis_data like below.
    LOOP AT t_cell_data INTO wa_t_cell_data.
      "Get the required data from t_cell_data.
      MOVE-CORRESPONDING wa_t_cell_data TO it_ur_tab.
      "Modify your internal table wih data
      MODIFY it_ur_tab TRANSPORTING <field1> <field2> <field3>.
    ENDLOOP.
    LOOP AT t_axis_data INTO wa_t_axis_data.
      "Get the required data from t_cell_data.
      MOVE-CORRESPONDING wa_t_axis_data TO it_ur_tab.
      "Modify your internal table wih data
      MODIFY it_ur_tab TRANSPORTING <field1> <field2> <field3>.
    ENDLOOP.
    Thanks
    Venkat.O

  • Read statement into an internal table

    Hi Experts,
    In my report i have several read statements, now my requirement is i want to put all the read statements into an internal table, how do i achieve it???
    Thank you!

    Hello Maya,
    i want to know how many number of times the read statement is used .
    Two ways:
    1. use a counter after each read statement in your program and increase it by 1 everytime there is read statement and display the final value of the counter in the report that you want.
    2. If you just want to know press (CNTRL + F) enter "READ" , select the radio button "In Main program" and then you will get all the read statement and can count it manually.
    Hope I have not answered your question wrong. But if I have, please be more specific about your requirement so that many an help you.
    Thanks,
    Jayant Sahu.

  • Read statement on dynamic internal tables

    Hello All,
    I have a dynamic internal table <G_T_ITAB> with fields F1, F2, F3 & F4 .
    I want to read the internal table <G_T_ITAB>. So im using the below code.
    LOOP AT G_T_DATA.
      READ TABLE <G_T_ITAB> INTO <G_R_ITAB> WITH KEY F1 = G_T_DATA-F1.
      IF SY-SUBRC <> 0.
      ELSE.
      ENDIF.
    ENDLOOP.
    But this is giving syntax error that F1 is not the field of <G_T_ITAB>. But the field is there in <G_T_ITAB>.
    Can you suggest me to solve this issue. Or is there any other approach to use READ statement on dynamic internal tables.
    Thanks in advance.
    Best Regards,
    Sasidhar Reddy Matli.

    Hi ,
    Read this way....
    FIELD-SYMBOLS:
    <fs_str> type any,
    <fs_lf_fval> type any,
    <fs_lt_result_rate> type any table,
    <fs_ls_result_rate> type any.
    DATA:
      lv_fname type string.
    lv_fname = 'MATNR'.
    assign component 'matnr' of structure <fs_str> to <fs_lf_fval>.
    READ TABLE <fs_lt_result_rate> INTO <fs_ls_result_rate>
                WITH KEY (lv_fname) = <fs_lf_fval>.
    Thanks,
    Shailaja Ainala.

  • Read data from STATIC internal table during round trip in DO_PREPARE_OUTPUT

    Dear Gurus
    I have a requirement where I need to select some data from the database table BUT_HIER_NODE_D.
    After SELECTING this data to an internal table (say ITAB), I am displaying this data in a table view. I was able to achive this functionality by putting some code in the DO_PREPARE_OUTPUT method.
    Now according to my requirement, after the above data has been displayed on the screen initially, the user will click on any row. After clicking on a particular row, I need to capture the document number on that particular row and need to display all its child document numbers in a separate table. I am able to achive this functionality also.
    Initially I am not sure of how to READ the same internal table (ITAB) again and again by avoiding the SELECT query upon each round trip (between CRM and Web).
    After some research, I understand that I might have to use STATIC internal table to store the data during the
    initial SELECT. This way, upon each round trip, I can READ the data from the same internal table.
    My question: But now, when I tried to create a STATIC internal table in DO_PREPARE_OUTPUT, it is not allowing me to declare this table because DO_PREPARE_OUTPUT method is a INSTANCE method.
    I didn't find any STATIC methods in the IMPL class of the view.
    I would really appreciate if somebody can help me on how to proceed further.
    Thanks
    Raj

    Hi Bharathy / Adil / Masood
    Thank you very much for the replies. I declared a static method inside the IMPL class and I was calling this method inside the DO_PREPARE_OUTPUT method. Looks like it is working fine for me...will comeback if I had any further issues.
    Masood
    As per my requirement, I need to Select the data into the internal table during the very first step, then I need to continuosly read the data from this internal table upon every round trip. So I am not sure if I would be able to use the method DO_INIT_CONTEXT. Because I need a method which will trigger upon each round trip and will also hold the data of this internal table. So right now, the only option for me is DO_PREPARE_OUTPUT method.
    Plz let me know if am doing in the right way.
    Thanks
    Raj

  • Problem reading data from nested internal table.

    Hi,
    Below is my code;
    *********SAP Code********
    TYPES: BEGIN OF v54a0_scdd,
             fknum  LIKE vfkk-fknum,
             change LIKE vfkkd-updkz,
             x      TYPE v54a0_scd,
             y      TYPE v54a0_scd,
             tvtf   LIKE tvtf,
           END OF v54a0_scdd.
    SCD table for dialog
    TYPES: v54a0_scdd_tab TYPE v54a0_scdd OCCURS 1.
    *********SAP Code********
    *Custom declaration*****
    data: wa_freight_costs type v54a0_scdd_tab.
    data: it_freight_costs type v54a0_scdd_tab occurs 0.
    *****Here data is getting appended to it_freight_costs. P_frieght_costs is coming from standard program.
         move p_freight_costs TO wa_FREIGHT_COSTS.
         append wa_freight_costs to it_freight_costs.
         clear wa_freight_costs.
    ***Now the problem is here. I am not able to read the data from the nested internal table x-item.
    if i use <fs_f_costs> to move data from it_freight_costs in the outer loop, i get a syntax error; <i> "the line type of the table it_freight_costs is not compatible with field symbol type <fs_f_costs>" </i>
         FIELD-SYMBOLS: <fs_f_costs> type line of v54a0_scdd_tab.
          LOOP AT it_freight_costs assigning <fs_f_costs>.
              LOOP AT <fs_f_costs>-x-item ASSIGNING <fs_freight_item>.        
                  <b> I want to read <fs_freight_item>-vfkp-netwr.</b> 
             ENDLOOP.
    Can anyone guide me?

    A quick look at how I would do this. Note I haven't checked if this compiles just done a quick brain-dump.
      DATA: lr_f_costs TYPE REF TO v54a0_scdd_tab,
            lr_f_cost TYPE REF TO v54a0_scdd.
      LOOP AT it_freight_costs REFERENCE INTO lr_f_costs.
        LOOP AT lr_f_costs->* REFERENCE INTO lr_f_cost.
        ENDLOOP.
      ENDLOOP.
    As you can see I personally prefer pointers to field symbols - I don't believe there is any performance differences and because of my background in other languages pointers make more sense to me.
    Cheers
    Graham Robbo

  • Read Statement in Dynamic Internal Table?

    Hi,
    Is it possible <b>read</b> statement in <b>Dynamic Internal</b> table?
    Thanls,
    Suresh.

    Hi,
    I think it will be possible. look at the following code u may get some idea.
    FORM field_check_blank  USING    pi_zcheck_name TYPE  zcheck_name
    pi_mara TYPE mara
    pi_keys TYPE yi_keys
    CHANGING pio_failed TYPE char1.
      DATA: li_ftab TYPE TABLE OF string,
            li_wtab TYPE TABLE OF string,
            l_tabnam TYPE string,
            l_tabfld TYPE string,
            l_txt TYPE string,
            lw_keys LIKE LINE OF pi_keys.
      CONSTANTS: lc_key_def TYPE string VALUE '&1 = &2-&1'.
      FIELD-SYMBOLS: <fval> TYPE ANY,
                     <fval2> TYPE ANY,
                     <fstruct> TYPE ANY.
      CLEAR: pio_failed.
      SPLIT pi_zcheck_name AT '-' INTO l_tabnam l_tabfld.
      APPEND l_tabfld TO li_ftab.
      ASSIGN (l_tabnam) TO <fstruct>.
      IF NOT sy-subrc EQ 0.
        MESSAGE e787 WITH l_tabnam.
      ENDIF.
      CLEAR: <fstruct>.
      LOOP AT pi_keys INTO lw_keys
      WHERE TABLE = L_TABNAM.
        ASSIGN COMPONENT lw_keys-field OF STRUCTURE <fstruct> TO <fval>.
        IF NOT sy-subrc EQ 0.
          MESSAGE e787 WITH lw_keys-field.
        ENDIF.
        ASSIGN COMPONENT lw_keys-field OF STRUCTURE pi_mara TO <fval2>.
        IF NOT sy-subrc EQ 0.
          MESSAGE e787 WITH lw_keys-field.
        ENDIF.
        <fval> = <fval2>.
        l_txt = lc_key_def.
        REPLACE ALL OCCURRENCES OF '&1' IN l_txt WITH lw_keys-field.
        REPLACE '&2' IN l_txt WITH lw_keys-table.
        IF NOT li_wtab IS INITIAL.
          CONCATENATE 'AND' l_txt INTO l_txt SEPARATED BY space.
        ENDIF.
        APPEND l_txt TO li_wtab.
      ENDLOOP.
      ASSIGN (pi_zcheck_name) TO <fval>.
      IF NOT sy-subrc EQ 0.
        MESSAGE e787 WITH pi_zcheck_name.
      ENDIF.
      SELECT SINGLE (li_ftab)
        INTO <fval>
        FROM (l_tabnam)
       WHERE (li_wtab).
      IF NOT sy-subrc EQ 0
      OR NOT <fval> IS INITIAL.
        pio_failed = c_true.
      ENDIF.
    ENDFORM.                    " FIELD_CHECK_BLANK
    Note:
    BEGIN OF y_keys,
             table TYPE tabname,
             field TYPE fieldname,
           END OF y_keys.
    If helpful pl reward.
    Cheers

  • LOBs reading out from iFS internal tables

    Hi, does anybody know how to read out the files which are stored in the database with iFS ? I would like to parse the files and put a couple of information out into an other table.

    Bernd, this is not a supported feature, and therefore is not documented. All access to iFS data should be through the iFS tools, Java APIs or the provided database Views (which do not include access to the LOBs).
    Why couldn't you use a protocol, such as FTP, or a java program to do what you want to do?

  • How to collect similar record from the internal table

    I need to collect exact matched records from 1 internal table to another internal table by searching 5 fields. I need to have records which are exactly matched for 5 fields. i have written a code wich is mention below it gave me only similar records but not 100% matched record.. would you like to help me. any correction, suggetion,. Will be great help to me.

    To get exact match of 5 records, do as follows.
    Check whether internal table gives only one record or not after READ statement.If internal table gives more than one entry for READ then the results will be improper.
    I think there is no need of READ statement on same internal table within LOOP. I commented the same in code.
    sort i_bp_p by title initials name_last idnumber idtype f50code rbcode. "acc_num.
    loop at i_bp_p into wa_i_bp_p.
    *lv_tabix = sy-tabix.
    *read table i_bp_p index lv_tabix into wa_i_bp_p.read table i_but0id into wa_but0id with key idnumber = wa_i_bp_p-idnumber
    idtype = wa_i_bp_p-idtype binary search.
    if sy-subrc = 0.
    read table i_but000 into wa_but000 with key title = wa_i_bp_p-title
    initials = wa_i_bp_p-initials
    name_last = wa_i_bp_p-name_last binary search.
    if sy-subrc = 0.
    read table i_but0is into wa_but0is with key f50code = wa_i_bp_p-f50code
    rbcode = wa_i_bp_p-rbcode binary search.
    if sy-subrc = 0.
    move-corresponding wa_i_bp_p to i_bp_p100.
    append i_bp_p100.
    endif.
    endif.
    endif.
    endloop.
    sort i_bp_p100 by partner.
    loop at i_bp_p100.
    write : /10 i_bp_p100-partner,
    20 i_bp_p100-title,
    30 i_bp_p100-initials,
    40 i_bp_p100-name_last,
    53 i_bp_p100-idnumber,
    70 i_bp_p100-idtype,
    85 i_bp_p100-rbcode,
    95 i_bp_p100-f50code.
    endloop.
    sort i_bp_p by title initials name_last idnumber idtype f50code rbcode. "acc_num.
    loop at i_bp_p into wa_i_bp_p.
    lv_tabix = sy-tabix.
    read table i_bp_p index lv_tabix into wa_i_bp_p.
    if sy-subrc = 0.
    read table i_but0id into wa_but0id with key idnumber = wa_i_bp_p-idnumber
    idtype = wa_i_bp_p-idtype binary search.
    if sy-subrc = 0.
    read table i_but000 into wa_but000 with key title = wa_i_bp_p-title
    initials = wa_i_bp_p-initials
    name_last = wa_i_bp_p-name_last binary search.
    if sy-subrc = 0.
    read table i_but0is into wa_but0is with key f50code = wa_i_bp_p-f50code
    rbcode = wa_i_bp_p-rbcode binary search.
    if sy-subrc = 0.
    move-corresponding wa_i_bp_p to i_bp_p100.
    append i_bp_p100.
    endif.
    endif.
    endif.
    endif.
    endloop.

  • How to read from an internal table with multiple key fields.

    Hi All!!
    I want to read from an internal table having keys as k1,k2,k3.
    How can I use read statement to read an entry having this as the key fields.
    Thanks in adavance..
    Prabhas Jha

    hi there
    use:
    sort itab by K1 K2 K3.
    read table itab into wa with key K1 = value 1
                                                  K2 = value2
                                                  K3 = value 3
                                                   BINARY SEARCH.
    where:
    itab is ur internal table
    wa is the work area with the same line type as the itab
    cheers
    shivika

  • Passing data to different internal tables with different columns from a comma delimited file

    Hi,
    I have a program wherein we upload a comma delimited file and based on the region( we have drop down in the selection screen to pick the region).  Based on the region, the data from the file is passed to internal table. For region A, we have 10 columns and for region B we have 9 columns.
    There is a split statement (split at comma) used to break the data into different columns.
    I need to add hard error messages if the no. of columns in the uploaded file are incorrect. For example, if the uploaded file is of type region A, then the uploaded file should be split into 10 columns. If the file contains lesser or more columns thenan error message should be added. Similar is the case with region B.
    I do not want to remove the existing split statement(existing code). Is there a way I can exactly pass the data into the internal table accurately? I have gone through some posts where in they have made use of the method cl_alv_table_create=>create_dynamic_table by passing the field catalog. But I cannot use this as I have two different internal tables to be populated based on the region. Appreciate help on this.
    Thanks,
    Pavan

    Hi Abhishek,
    I have no issues with the rows. I have a file with format like a1,b1,c1,d1,e1, the file should be uploaded and split at comma. So far its fine. After this, if the file is related to region A say Asia, then it should have 5 fields( as an example). So, all the 5 values a1,b1..e1 will be passed to 5 fields of itab1.
    I also have region B( say Europe)  whose file will have only 4 fields. So, file is of the form a2,b2,c2,d2. Again data is split at comma and passed to itab2.
    If some one loads file related to Asia and the file has only 4 fields  then the data would be incorrect. Similar is the case when someone tries to load Europe file with 5 fields related data. To avoid this, I want to validate the data uploaded. For this, I want to count the no. of fields (seperated by comma). If no. of fields is 5 then the file is related to Asia or if no. of fields is 4 then it is Europe file.
    Well, the no. of commas is nothing but no. of fields - 1. If the file is of the form a1,b1..e1 then I can say like if no. of commas = 4 then it is File Asia.But I am not sure how to write a code for this.Please advise.
    Thanks,
    Pavan

  • How to split all the fields of output ls-l from an internal table

    Hi all,
    Using ls-l command i have brought the file attributes of a file like its read and write permissions,creation date ,path etc in a internal table.
    Now how to split all these fields from the internal table or what should be the splitting criteria.
    The field contents of internal table are like this:
    -rw-rw----    1  devadm     sapsys     18360    apr  29......so on
    I want to split this into different fields.
    Kindly suggest.
    Thank You.

    Hi,
    I think the delimiter will be space. For date alone (Apr 29) you need to concatenate after the string has been split.
    Thanks and regards,
    S. Chandramouli

  • Help needed to get unique record from an internal table

    Hi Everybody,
    I have to get unique record from an internal table. i know we can use read statement with key condition .
    But the problem is i have to use some relational operators like GE or LE.
    eg
    read table itab into wa with key width GE itab-widthfrom
                                                       width LE itab-widthto
                                                       machno eq itab-machno.
    Its giving me error when I use the operators GE , LE.( I think since it can't find a unique record with those relational
    operators in the with key statement)
    Is there any other way to get unique record from internal table without using the loop?
    Thanks,
    Sunny

    Using the read statement you will need some kind of loop. For example.
    DO.
    READ TABLE......
      WITH KEY ......
                        READ = SPACE
    IF SY-SUBRC EQ 0
      TABLE-READ = 'X'.
      MODIFY TABLE
      ADD 1 TO W_FOUND.
    ELSE
      EXIT.
    ENDIF
    ENDDO.
    IF W_FOUND EQ 1.
    ...record is unique.
    ENDIF.

  • Select Data from 2 intern tables

    Hi Experts,
    how I can select Data from 2 intern Tables into another intern table?
    For Example:
    My Result  Table has the fields: mandt, user, ID, ID_Name.
    My select table no. 1 has the fields mandt, XYZ (like A_Name), ID, ID_Name, ...
    My select table no. 2 has the fields mandt, A_Name, User, ...
    I want to search for all entries in select table no. 1 and 2. where are a_name have the same worth.
    How I can select my Dates?
    Regards,
    Mike

    hii
    you can do it by using for all entries and with READ statement ..do like follow code
    IF i_marc[] IS NOT INITIAL.
        SELECT matnr                       " Material Number
               werks                       " Plants
               lgort                       " Storage Location
          FROM mard
          INTO TABLE i_mard
           FOR ALL ENTRIES IN i_marc
         WHERE matnr EQ i_marc-matnr
           AND werks EQ i_marc-werks
           AND lgort IN s_lgort.
      ENDIF.                               " IF i_mara[] IS NOT INITIAL
      IF sy-subrc EQ 0.
        LOOP AT i_output INTO wa_output.
          READ TABLE i_mard INTO wa_mard WITH KEY matnr = wa_output-matnr.
          wa_output-lgort = wa_mard-lgort.
          MODIFY i_output FROM wa_output.
          CLEAR wa_output.
        ENDLOOP.                           " LOOP AT i_output
      ENDIF.                               " IF sy-subrc EQ 0
    regards
    twinkal

Maybe you are looking for