Logic in a internal table

hi experts , i need a logic
i have a internal table itab_equi in that i am getting 11 values when i pass this internal table to another table using for all entries i will get 4 values in int_bmgkobj . i need logic for how to get the deleted values  i.e 9 values deleted . i need that value 9 values ..
SELECT matnr
           sernr
           kunde
           objnr FROM equi
           INTO TABLE itab_equi  " i am getting 11 values here
           WHERE kunde = kunde .
IF itab_equi[] IS NOT INITIAL.
      SELECT j_objnr
                   gwldt
                   gwlen FROM bgmkobj
                   INTO TABLE itab_bgmkobj " i am getting 4 values here
                   FOR ALL ENTRIES IN itab_equi
                   WHERE j_objnr = itab_equi-objnr .
i need the deleted 9 values in a seperate internal table ..
plz help me for this logic
regards
chinnaiya P

HI,
Check this ..
SELECT matnr
           sernr
           kunde
           objnr FROM equi
           INTO TABLE itab_equi  " i am getting 11 values here
           WHERE kunde = kunde .
IF itab_equi[] IS NOT INITIAL.
      SELECT j_objnr
                   gwldt
                   gwlen FROM bgmkobj
                   INTO TABLE itab_bgmkobj " i am getting 4 values here
                   FOR ALL ENTRIES IN itab_equi
                   WHERE j_objnr NE itab_equi-objnr .  "--> Check here
Or
Select all the data from bgmkobj into internal table  itab_bgmkobj.
Loop the  itab_bgmkobj and check the entry using entries in internal table itab_equi..if found delete ..the left entries are what you required

Similar Messages

  • Logic issue with Internal Table

    Hi All,
    I have an internal table with following structure.
    Name of Internal table: ITAB
    Fields:   userid      login date     number
    Values:  abc         01012008    
                 abc         02012008
                 abc         02012008
                 abc         03012008
    Now i should store the value for the field itab-number, based on the ita-logindate.
    If the field logindate is having same date for 2 times (for the user 'abc'),
    the field itab-number should have the value as '2' .
    Basically i want to display a report to show how many times a user has logged into SAP system for a given date.......
    How to incorporate this logic?
    Regards
    Pavan

    Hi,
    Use the below logic.
    data: begin of itab1 occurs 0,
           uid  like sy-uname,
           date like sy-datum,
          end of itab1.
    data: begin of itab2 occurs 0,
           uid  like sy-uname,
           date like sy-datum,
           count type i,
          end of itab2.
    data v_count type i.
    start-of-selection.
    itab1-uid = 'abc'.
    itab1-date = '20080101'.
    append itab1.
    itab1-uid = 'abc'.
    itab1-date = '20080102'.
    append itab1.
    itab1-uid = 'abc'.
    itab1-date = '20080102'.
    append itab1.
    itab1-uid = 'abc'.
    itab1-date = '20080103'.
    append itab1.
    itab1-uid = 'abc'.
    itab1-date = '20080104'.
    append itab1.
    sort itab1 by uid date.
    loop at itab1.
    v_count = v_count + 1.
    at end of date.
    itab2-uid = itab1-uid.
    itab2-date = itab1-date.
    itab2-count = v_count.
    append itab2.
    clear  v_count.
    endat.
    endloop.

  • Simple logic from below internal tables

    Hi,
    I have one i.table ITAB.
    entries as:
    Year   Month    value
    2008   12         0.00
    I have another i.table ITAB1
    entries as:
    Year       Month   value
    2008       1          12.00
    2008       2          15.00
    2008       3          10.00
    2008       4          11.00  
    2008       11         0.00 
    2008       12         0.00
    Both these i.tables are retrieved from same table.
    Now i required logic such that i should be able check each month 12-1, 11-1 etc.. till the month have some value other than 0.00.
    Note: i should not use
    Loop at ITAB.
    If itab-value eq 0.
    logic should pick up value from previous available month which have value from ITAB1
    endif.
    endloop.
    can anybody provide simple logic for this!
    Thanks,
    Deep.

    Hi,
    do we have to get a non zero value for a record in ITAB, from a previous period record, as here, from ITAB1? And wat we can't use ? please clarify..
    If yes...
    SORT ITAB BY ASCENDING YEAR MONTH.
    SORT ITAB1 BY DESCENDING YEAR MONTH.
    FLAG = 0.
    LOOP AT ITAB.
    FLAG = 0.
    IF ITAB-VALUE EQ 0.
    LOOP AT ITAB1.
    IF ITAB1-YEAR = ITAB-YEAR AND ITAB1-MONTH AND ITAB-MONTH.
    FALG = 1.           " matching record found
    ENDIF.
    IF FLAG EQ 1.           " once record found we need to go further nd find a non-zero value as
                                     " sorted  descending order we will get value from previous possible record.
    IF ITAB1-VALUE NE 0.
    MODIFY ITAB FROM ITAB1.
    FLAG = 0.
    ENDIF.
    ENDLOOP.
    ENDLOOP.
    -pranav

  • Transpose  Internal table

    Hi,
    I want the logic how to transpose the internal table i.e colums to rows and rows to columns.
    for example I have a internal table like
    A B C D E F
    a b c d  e f
    1 2 3 4 5 6
    I want it as
    A a 1
    B b c
    C c 3
    D d 4
    E e 5
    F f 6
    How to do the Same.
    The problem is that I dont know until the run time the number of rows
    I know its asked but I couldnt find them
    Regards
    Edited by: SAP LEARNER on Apr 20, 2009 2:43 PM

    hi ,
    You can try this code, Hope this helps you.
    REPORT  ZTRANSPOSE_PAV.
    data : BEGIN OF itab OCCURS 0,
           a(10) type c,
           b(10) type c,
           c(10) type c,
           d(10) type c,
           e(10) type c,
           END OF itab.
        itab-a = 'A'.
        itab-b = 'B'.
        itab-c = 'C'.
        itab-d = 'D'.
        itab-e = 'E'.
        APPEND itab.
         itab-a = 'a'.
        itab-b = 'b'.
        itab-c = 'c'.
        itab-d = 'd'.
        itab-e = 'e'.
        APPEND itab.
         itab-a = '1'.
        itab-b = '2'.
        itab-c = '3'.
        itab-d = '4'.
        itab-e = '5'.
        APPEND itab.
      LOOP AT  itab.  "  Just for Displaying the Internal Table
        WRITE :/ itab-a,itab-b,itab-c,itab-d,itab-e.
      ENDLOOP.
      skip 5.
    *********************Logic to Transpose  Internal Table******************** 
      loop at itab.
        write  itab-a.
        ENDLOOP.
        skip.
        loop at itab.
        write  itab-b.
        ENDLOOP.
       skip.
        loop at itab.
        write  itab-b.
        ENDLOOP.
        skip.
        loop at itab.
        write  itab-d.
        ENDLOOP.
        skip.
        loop at itab.
        write  itab-e.
        ENDLOOP.

  • Run Time Internal Table

    Hi,
          My requirement is in routine.I need to capture the value of an internal table and move it to another dummy internal table for some logic.But the internal table is run time internal table.
    How to assign this internal table value to Field symbol.
    Thanks in advance.
    Ashok

    can't you just define your dummy itab like your existing itab then move the contents?
    dumm_itab[ ] = itab[ ]
    Edited by: robert phelan on Sep 25, 2008 8:37 PM

  • Logic for retreiving the values from a dynamic internal table

    Hi all,
    I have an issue with the logic to fetch data from a dynamic internal table into fields. let me give you guys an example the sy-tfill = 9 (subject to vary). I need to populate the fields.
    Regards,
    Sukumar

    Hi,
    this is for printing out the info in a dynamic table,
    it will work likewise to insert data.
    PARAMETERS:
      p_tabnam TYPE tabname DEFAULT 'DB_TABLE_NAME'.
    DATA:
      lv_dref TYPE REF TO data,
      ls_dd03l LIKE dd03l,
      lt_fieldname TYPE TABLE OF fieldname,
      ls_fieldname TYPE fieldname.
    FIELD-SYMBOLS:
      <fs> TYPE STANDARD TABLE,
      <wa_comp> TYPE fieldname,
      <wa_data> TYPE ANY,
      <wa_field> TYPE ANY.
    REFRESH lt_fieldname.
    SELECT * FROM dd03l INTO ls_dd03l
                       WHERE as4local = 'A'
                         AND as4vers  = '0000'
                         AND tabname  = p_tabnam
                       ORDER BY position.
      ls_fieldname = ls_dd03l-fieldname.
      APPEND ls_fieldname TO lt_fieldname.
    ENDSELECT.
    IF NOT ( lt_fieldname[] IS INITIAL ).
      CREATE DATA lv_dref TYPE TABLE OF (p_tabnam).
      ASSIGN lv_dref->* TO <fs>.
      SELECT * FROM (p_tabnam) INTO TABLE <fs>.
      WRITE:
        / 'CONTENTS OF TABLE', p_tabnam.
      LOOP AT <fs> ASSIGNING <wa_data>.
        SKIP.
        WRITE:
          / 'LINE', sy-tabix.
        ULINE.
        LOOP AT lt_fieldname ASSIGNING <wa_comp>.
          ASSIGN COMPONENT sy-tabix OF STRUCTURE <wa_data> TO <wa_field>.
          WRITE:
            / <wa_comp>, <wa_field>.
        ENDLOOP.
      ENDLOOP.
    ENDIF.
    grtz
    Koen

  • Logic issues for manipulation of internal table data

    Hi,
    I am having a issue with logic of one program.
    In the <b>XVBAP</b> internal table of <b>SO</b> User Exit.
    We will have fields like
    <b>UPDKZ, POSNR, UEPOS, ZZECD[Z-Field] etc.</b>
    Above fields are related to logic.
    1. Now my first point is:
    <b>We need to capture Records where UPDKZ='D' and ZZECD[Z-Field] is populated.</b>
    For this we will write code as below:
    <b>LOOP AT XVBAP WHERE UPDKZ     EQ C_D   AND
                        ZZECD     NE SPACE.
    Here we will store all fields in I_XVBAP I.Table
    ENDLOOP.</b>
    Supoose we have retrieved records as below:
    <b>VBELN, UPDKZ, POSNR, UEPOS, ZZECD
    100    D   000040   000030 Text1
    100    D   000050   000020 Text2
    100    D   000060   000000 Text3</b>
    2. My second point here is:
    <b>For Every Item[POSNR] we need to get the Higher level item from UEPOS field, If the Higher level Item also has UPDKZ = ‘D’, then move the base unit and all it’s components into an internal table. continue this process till UEPOS for POSNR is 000000 but High item should have UPDKZ = 'D', not only this all items in this chain should have UPDKZ = 'D'.</b>
    Ex:
    <b>Suppose for item 000050 UEPOS is 000020 then goto XVBAP with POSNR = UEPOS[000020] and UPDKZ = 'D' if yes and then pick up UEPOS for 000020 item and continue this process till UEPOS becomes 000000 and UPDKZ = 'D'.
    Here from Low level to High level all the chain items should have UPDKZ = 'D'. Then only write all items into Final Internal table.</b>
    <b>Need to do this process for all above rec's [40,50,60 - POSNR].</b>
    Can anybody provide me the logic for the above scenario.
    Thanks in advance.
    Thanks and Regards,
    Deep

    Hi Anurag,
    Your assumption is wrong.
    See first when we get into our logic we will get <b>XVBAP</b> data as below:
    <b>VBELN, POSNR, UEPOS, UPDKZ, ZZECD
    100,  10,  00,  D,  Text1
    100,  20,  00,   ,  Text2
    100,  30,  20,  D,  Text3
    100,  40,  30,  D,  Text4
    100,  50,  00,   ,  Text5
    100,  60,  00,   D, Text6
    100,  70,  60,   D, Text7</b>
    After we run first point we will get data as:
    Here logic is pick up data where <b>UPDKZ = D</b> and <b>ZZECD NE SPACE</b>.
    <b>VBELN, POSNR, UEPOS, UPDKZ, ZZECD
    100, 10, 00, D, Text1
    100, 30, 20, D, Text3
    100, 40, 30, D, Text4
    100, 60, 00, D, Text6
    100, 70, 60, D, Text7</b>
    Then we will goto second point:
    Here we need to look into <b>3</b> things totally in 2nd point:
    1. In loop Select the record which has <b>UEPOS EQ space</b>, <b>UPDKZ = D</b> and <b>POSNR</b> should not be <b>UEPOS</b> for any other record from above data from 1st point.
    <b>100, 10, 00, D, Text1</b>
    will be selected into final internal table as per this point.
    2. If for a POSNR value UEPOS NE SPACE, UPDKZ = D then goto UEPOS's POSNR in high level check there if UPDKZ = D and then wether UEPOS is ZERO (or) contains any value.
    If any value is there repeat the process till UEPOS become ZERO. Then for that final higher level item check UPDKZ value if it has value as 'D', If has then write all those records from low item to high item into final internal table.
    <b>100, 60, 00, D, Text6
    100, 70, 60, D, Text7</b>
    In above for Item 70[POSNR] we have UEPOS as 60 and UPDKZ as D. then we will goto UEPOS's POSNR, Now POSNR is 60 then check it's UEPOS it is ZERO so check UPDKZ because it is D write both items 60, 70 into final internal table.
    2. If for a POSNR value UEPOS NE SPACE, UPDKZ = D then goto UEPOS's POSNR in high level check there if UPDKZ = D and then wether UEPOS is ZERO (or) contains any value.
    If any value is there repeat the process till UEPOS become ZERO. Then for that final higher level item check UPDKZ value if it has value as 'D', If it does not have  UPDKZ as 'D' then don't write any item from low to high into final internal table.
    If we take the scenario of below rows:
    <b>100,  20,  00,   ,  Text2
    100,  30,  20,  D,  Text3
    100,  40,  30,  D,  Text4</b>
    POSNR-40 has UEPOS-30 & UPDKZ = D then UEPOS's POSNR-30 has UEPOS-20 and UPDKZ-D then UEPOS POSNR-20 has UEPOS as 00 then stop here and see UPDKZ which is ZERO so don't consider items 20,30,40 into final i.table.
    In the above chain in any record UPDKZ is not 'D' then skip the process anddon't write the records into final internal table.
    Final output will come as:
    <b>100, 10, 00, D, Text1</b>
    <b>100, 60, 00, D, Text6
    100, 70, 60, D, Text7</b>
    Thanks for all your efforts.
    Thanks,
    Deep

  • Internal table logic issue

    Hi All,
    I have one logical issue related to internal table manipulation.
    I have one internal table :
    I_DAT - This is related to Loading/Unloading of Goods.
    for example with 3 fields
    VSTEL, KUNNA, KMMANG.
    Now suppose my data looks like this after sorting:
    VSTEL   KUNNA    KMMANG
    100       -        -
    200       -        -
    300       -        -
    400       -        -
    -         500      X
    -         600      X
    -         700      X
    -         800      X
    Here 100,200,300,400 are Loading points.
    ANd 500,600,700,800 are unloading points.
    Now what i want is For loading & Unloading points i need to pick up Address and print one after other.
    But how they need to print is:
    FOR INITIAL LOADING OF
    ADDRESS- For 100
    FIRST STOP: FOR LOADING OF
    ADDRESS- For 200
    SECOND STOP: FOR LOADING OF
    ADDRESS- For 300
    Etc .....
    Then
    FOR UNLOADING OF:
    ADDRESS- For 400
    FIRST STOP: FOR UNLOADING OF
    etc.
    FINAL STOP: FOR FINAL UNLOADING OF
    We might get as many records :
    Can any body give me the logic:
    Printing Address is not a problem:
    But Above every address we need to print FIRST STOP, SECOND etc like that.
    For this i need logic.
    Can anybody give the solution!
    Thanks in advance.
    Thanks & Regards,
    Prasad.

    Try this.I think you want output like this......
    DATA: BEGIN OF LINE,
            CARRID   TYPE SBOOK-CARRID,
            CONNID   TYPE SBOOK-CONNID,
            FLDATE   TYPE SBOOK-FLDATE,
            CUSTTYPE TYPE SBOOK-CUSTTYPE,
            CLASS    TYPE SBOOK-CLASS,
            BOOKID   TYPE SBOOK-BOOKID,
          END OF LINE.
    DATA ITAB LIKE SORTED TABLE OF LINE WITH UNIQUE KEY TABLE LINE.
    SELECT CARRID CONNID FLDATE CUSTTYPE CLASS BOOKID
           FROM SBOOK INTO CORRESPONDING FIELDS OF TABLE ITAB.
    LOOP AT ITAB INTO LINE.
      AT FIRST.
        WRITE / 'List of Bookings'.
        ULINE.
      ENDAT.
        AT NEW CARRID.
          WRITE: / 'Carrid:', LINE-CARRID.
        ENDAT.
          AT NEW CONNID.
            WRITE: / 'Connid:', LINE-CONNID.
          ENDAT.
            AT NEW FLDATE.
              WRITE: / 'Fldate:', LINE-FLDATE.
            ENDAT.
              AT NEW CUSTTYPE.
                WRITE: / 'Custtype:', LINE-CUSTTYPE.
              ENDAT.
                   WRITE: / LINE-BOOKID, LINE-CLASS.
                AT END OF CLASS.
                  ULINE.
                ENDAT.
    ENDLOOP.
    This is also helpful......
    LOOP AT <itab>.
      AT FIRST. ... ENDAT.
        AT NEW <f1>. ...... ENDAT.
          AT NEW <f2 >. ...... ENDAT.
              <single line processing>
          AT END OF <f2>. ... ENDAT.
        AT END OF <f1>. ... ENDAT.
      AT LAST. .... ENDAT.
    ENDLOOP.
    Regards
    Abhishek

  • Logic in internal table -- Urgent

    Hi All,
    I have an internal table idoc_data of structure
          DOCNUM  SEGNUM  SEGNAM       
          3164     00001  E1STZUM -
    1st idoc
          3164     00002  E1MASTM
          3164     00003  E1MARAM
          3164     00004  E1MAKTM
          3164     00005  E1STPOM -
    end of 1st idoc
          3164     00006  E1STZUM  -
    2nd idoc
          3164     00007  E1MASTM
          3164     00008  E1MARAM
          3164     00009  E1STPOM -
    end of 2nd idoc
          3164     00010  E1STZUM  -
    3rd idoc
          3164     00011  E1MASTM
          3164     00012  E1MARAM
          3164     00013  E1STPOM  -
    end of 3rd idoc
          and so on .........
    "Pls note that the idocs are collected into a single idoc having same DOCNUM 3164".
    I have to write a logic like this.
    Loop at idoc_data.
    Move the first idoc record starting from E1STZUM -
    1st idoc till E1STPOM----end of 1st idoc into a temporary internal table and call master_idoc_distribute to send an idoc out.
    Move the second idoc record starting from E1STZUM  -
    2nd idoc till E1STPOM -
    end of 2nd idoc into the temporary internal table and call master_idoc_distribute to send an idoc out.
    Move the third idoc like the same and so on........for the whole idocs. 
    There could be even more than 5000 idocs in the same structure having same idoc number.
    Any help in writing the logic is really appreciated. Pls send me the whole code itself. It is an urgent reqmt. So pls do the needful.....
    Thanks
    Ricky

    Will explain one more time.
    Internal table structure
    DOCNUM SEGNUM SEGNAM
    3164 00001 E1STZUM -
    1st idoc
    3164 00002 E1MASTM
    3164 00003 E1MARAM
    3164 00004 E1MAKTM
    3164 00005 E1STPOM
    3164 00006 Z1MARZ -
    end of 1st idoc (this could be more than one )
    3164 00007 E1STZUM -
    2nd idoc
    3164 00008 E1MASTM
    3164 00009 E1MARAM
    3164 00010 E1STPOM
    3164 00011 Z1MARZ -
    end of 2nd idoc (this could be more than one)
    3164 00010 E1STZUM -
    start of 3rd idoc
    3164 00011 E1MASTM
    3164 00012 E1MARAM
    3164 00013 E1STPOM
    3164 00014 Z1MARZ     -
    end of 3rd idoc (this could be more than one)
    and so on.........
    "Pls note that the idocs are collected into a single idoc having same DOCNUM 3164".
    I have to write a logic like this.
    Loop at idoc_data.
    Move the first idoc record starting from E1STZUM -
    1st idoc till Z1MARZ----end of 1st idoc into a temporary internal table and call '' FM master_idoc_distribute'' to send an idoc out.
    Move the second idoc record starting from E1STZUM -
    2nd idoc till Z1MARZ -
    end of 2nd idoc into the temporary internal table and call FM "master_idoc_distribute" to send an idoc out.
    Move the third idoc like the same and so on........for the whole idocs.
    There could be even more than 5000 idocs in the same structure having same idoc number.
    Any help in writing the logic is really appreciated. Pls send me the whole code itself. It is an urgent reqmt. So pls do the needful.....
    Thanks

  • Need a logic for Internal table processing

    Hi,
    I have a requirement...an internal table contains three fields material no, bin no, and Quantity
    Mat. No    |         Bin No        |              Quantity
    a              |              x1         |                   10
    a              |              x1         |                   10
    a              |              x2         |                   20
    b              |              x3         |                   10 
    c              |              x3         |                   20
    c              |              x4         |                   30
    c              |              x4         |                   40
    In this I need to append the records to new internal table say itab1 where multiple entries exist for some material no like mat no 'a' and 'c'  and
    if the material no. exist only once in the table, it has to be moved to another new internal table say itab2.
    Pls suggest some logic that does not have performance issues.
    Thanks in advance
    Saravana

    Hi there,
    a solution in brief...
    data: wa_itab1_a like itab1,
             wa_itab2_b like itab1,
             lv_tabix       type sytabix.
    sort itab1 by matnr.
    loop at itab1.
      wa_itab1_a = itab1.
      at new matnr.
        lv_tabix = sy-tabix + 1.
        clear wa_itab2_b.
        READ TABLE itab1 into wa_itab2_b
                            INDEX lv_tabix.
        if wa_itab2_b-matnr ne wa_itab1_a-matnr.
          append wa_itab1_a to itab2.
          delete itab1 where matnr = wa_itab1_a-matnr.
        endif.
      endat.
    endloop.
    Regards
    George Zervas
    Edited by: gzervas on Oct 20, 2010 12:08 PM

  • Need logic in Internal table processing

    Hi all,
    I have requirement like this.
    i cretaed  three internal tables
    1) first Internal table can store total uploaded data from flat file..means line by line( Here each line is one record)
    2) Second internal can store all fields which are fetched based on table which is given on selction screen.
    3)now i cretaed one internal table with one variable
    4) i used spilt statement on first internal table ( which store all flat file recrds) into third internal table.
    so , my third internal table has first records values of first internal table in one column.
    Now my probelm...i need to populate bapi structre tables with values of third internal table based on field names of second internal table. i am not able to do logic.
    Is there any pointers to know soultion
    Note:we know which fields values from flat values  needs to populate Bapi structure table..
    Thanks in advance,
    regards,
    JBR

    check this program may be u will get the logic
    *& Report  ZBAPI_MATERIAL_SAVEDATA
    *& PURPOSE : THIS REPORT USES BAPI MATERIAL SAVE DATA TO UPDATE AND CREATE
    *&           THE MATERIAL
    REPORT  ZBAPI_MATERIAL_SAVEDATA NO STANDARD PAGE HEADING MESSAGE-ID (ZHNC).
    TYPES:BEGIN OF TY_MAT,
           MATERIAL(4),
           IND_SECTOR(1),
           MATL_TYPE(4),
           MATL_GROUP(9),
           BASE_UOM(3),
           BASE_UOM_ISO(3),
           PLANT(4),
           DEL_FLAG(1),
           PUR_GROUP(3),
           BASE_QTY(13),
           STGE_LOC(4),
           MRP_IND(1),
           SALES_ORG(4),
           DISTR_CHAN(2),
           DEL_FLAG1(1),
           MIN_ORDER(13),
           LANGU(2),
          MATL_DESC(40),
       END OF TY_MAT.
    DATA: IT_DATA TYPE TABLE OF TY_MAT,
          WA_DATA LIKE LINE  OF IT_DATA.
    *decalraing flag
    data: v_flag value ''.
    *DECLARING WORK AREAs  TO BE PASSED TO THE FUNCTION MODULE.
    DATA: BAPI_HEAD LIKE BAPIMATHEAD,
          BAPI_CLIENTDATA LIKE BAPI_MARA,
          BAPI_CLIENTDATAX LIKE BAPI_MARAX,
          BAPI_PLANTDATA LIKE BAPI_MARC,
          BAPI_PLANTDATAX LIKE  BAPI_MARCX,
          BAPI_STORAGELOCATIONDATA LIKE BAPI_MARD,
          BAPI_STORAGELOCATIONDATAX LIKE BAPI_MARDX,
          BAPI_SALESDATA LIKE BAPI_MVKE,
          BAPI_SALESDATAX LIKE BAPI_MVKEX,
          BAPI_MAKT LIKE BAPI_MAKT,
          BAPI_RETURN LIKE BAPIRET2.
    *INTERNAL TABLE TO HOLD THE MATERIAL DESCRIPTION
    DATA: BEGIN OF IT_MAKT OCCURS 0.
    INCLUDE STRUCTURE BAPI_MAKT.
    DATA END OF IT_MAKT.
    DATA:BEGIN OF IT_RET OCCURS 0.
    INCLUDE STRUCTURE BAPIRET2.
    DATA END OF IT_RET.
    *INTERNAL TABLE TO HOLD HEADER DATA
    DATA: IT_EXCEL TYPE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
    *SELECTION-SCREEN ELEMENTS
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    PARAMETER: FNAME TYPE RLGRAP-FILENAME OBLIGATORY DEFAULT 'C:\Documents and Settings\Administrator\Desktop\MATMAS.XLS' .
    PARAMETERS: P_BEGCOL TYPE I DEFAULT 1 NO-DISPLAY,
                P_BEGROW TYPE I DEFAULT 1 NO-DISPLAY,
                P_ENDCOL TYPE I DEFAULT 100 NO-DISPLAY,
                P_ENDROW TYPE I DEFAULT 32000 NO-DISPLAY.
    SELECTION-SCREEN END OF BLOCK B1.
    *DECLARATION OF EXCELAL TABLE
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR FNAME.
    PERFORM F_GET_FILE USING FNAME.
    START-OF-SELECTION.
    PERFORM F_XLS_ITAB USING FNAME
                       CHANGING IT_EXCEL.
    PERFORM F_MOVE_DATA.
    perform F_GET_DATA.
    *&      Form  F_GET_FILE
          text
         -->P_FNAME  text
         <--P_SY_SUBRC  text
    FORM F_GET_FILE  USING    P_FNAME LIKE FNAME.
    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
       PROGRAM_NAME        = SYST-REPID
       DYNPRO_NUMBER       = SYST-DYNNR
      FIELD_NAME          = ' '
      STATIC              = ' '
      MASK                = ' '
      CHANGING
        FILE_NAME           = P_FNAME
    EXCEPTIONS
      MASK_TOO_LONG       = 1
      OTHERS              = 2
    IF SY-SUBRC <> 0.
    MESSAGE E006(ZHNC).
    ENDIF.
    ENDFORM.                    " F_GET_FILE
    *&      Form  F_XLS_ITAB
          text
         -->P_FNAME  text
         <--P_IT_EXCEL  text
    FORM F_XLS_ITAB  USING    P_FNAME
                     CHANGING P_IT_EXCEL.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        FILENAME                      = FNAME
        I_BEGIN_COL                   = P_BEGCOL
        I_BEGIN_ROW                   = P_BEGROW
        I_END_COL                     = P_ENDCOL
        I_END_ROW                     = P_ENDROW
      TABLES
        INTERN                        = IT_EXCEL
    EXCEPTIONS
       INCONSISTENT_PARAMETERS       = 1
       UPLOAD_OLE                    = 2
       OTHERS                        = 3
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM.                    " F_XLS_ITAB
    *&      Form  F_MOVE_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM F_MOVE_DATA .
    DATA : LV_INDEX TYPE I.
    FIELD-SYMBOLS <FS>.
    *--- Sorting the internal table
    SORT IT_EXCEL BY ROW COL.
    CLEAR IT_EXCEL.
    LOOP AT IT_EXCEL.
    MOVE IT_EXCEL-COL TO LV_INDEX.
    *--- Assigning the each record to an internal table row
    ASSIGN COMPONENT LV_INDEX OF STRUCTURE WA_DATA TO <FS>.
    *--- Asigning the field value to a field symbol
    MOVE IT_EXCEL-VALUE TO <FS>.
    AT END OF ROW.
    APPEND WA_DATA TO IT_DATA.
    CLEAR WA_DATA.
    ENDAT.
    ENDLOOP.
    ENDFORM.                    " F_MOVE_DATA
    *&      Form  F_GET_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM F_GET_DATA .
    LOOP AT IT_DATA INTO WA_DATA.
    MOVE-CORRESPONDING WA_DATA  TO  BAPI_HEAD.
    BAPI_HEAD-BASIC_VIEW ='X'.
    BAPI_HEAD-SALES_VIEW ='X'.
    BAPI_HEAD-PURCHASE_VIEW ='X'.
    BAPI_HEAD-STORAGE_VIEW ='X'.
    MOVE-CORRESPONDING WA_DATA TO BAPI_CLIENTDATA.
    BAPI_CLIENTDATAX-MATL_GROUP = 'X'.
    BAPI_CLIENTDATAX-BASE_UOM = 'X'.
    BAPI_CLIENTDATAX-BASE_UOM_ISO = 'X'.
    MOVE-CORRESPONDING WA_DATA TO BAPI_PLANTDATA.
    BAPI_PLANTDATAX-PLANT = BAPI_PLANTDATA-PLANT.
    BAPI_PLANTDATAX-DEL_FLAG = 'X'.
    BAPI_PLANTDATAX-PUR_GROUP = 'X'.
    BAPI_PLANTDATAX-BASE_QTY = 'X'.
    MOVE-CORRESPONDING WA_DATA TO BAPI_STORAGELOCATIONDATA.
    BAPI_STORAGELOCATIONDATA-PLANT = BAPI_PLANTDATA-PLANT.
    BAPI_STORAGELOCATIONDATAX-PLANT = BAPI_STORAGELOCATIONDATA-PLANT.
    BAPI_STORAGELOCATIONDATAX-STGE_LOC = BAPI_STORAGELOCATIONDATA-STGE_LOC.
    BAPI_STORAGELOCATIONDATAX-MRP_IND = 'X'.
    MOVE-CORRESPONDING WA_DATA TO BAPI_SALESDATA.
    BAPI_SALESDATAX-SALES_ORG = BAPI_SALESDATA-SALES_ORG.
    BAPI_SALESDATAX-DISTR_CHAN = BAPI_SALESDATA-DISTR_CHAN.
    BAPI_SALESDATAX-DEL_FLAG = BAPI_SALESDATA-DEL_FLAG.
    BAPI_SALESDATAX-MIN_ORDER = 'X'.
    REFRESH IT_MAKT.
    IT_MAKT-LANGU = WA_DATA-LANGU.
    IT_MAKT-MATL_DESC = WA_DATA-MATL_DESC.
    APPEND IT_MAKT.
    CLEAR IT_RET.
    REFRESH IT_RET.
    PERFORM F_CALL_BAPI.
    READ TABLE IT_RET WITH KEY TYPE = 'S'.
    IF SY-SUBRC EQ 0.
    PERFORM F_BAPI_COMMIT.
    WRITE:/ 'MATERIAL CREATED OR UPDATED SUCESSFULLY WITH MATERIAL NO',WA_DATA-MATERIAL.
    ELSE.
    MESSAGE E000(ZHNC) WITH 'ERROR IN CREATING THE MATERIAL'.
    *WRITE: / 'ERROR IN CREATIN MATERIAL',IT_RET-MESSAGE.
    *PERFORM F_DOWNLOAD.
    ENDIF.
    *ENDIF.
    ENDLOOP.
    ENDFORM.                    " F_GET_DATA
    *&      Form  F_CALL_BAPI
          text
    -->  p1        text
    <--  p2        text
    FORM F_CALL_BAPI .
    CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
      EXPORTING
        HEADDATA                   = BAPI_HEAD
       CLIENTDATA                 =  BAPI_CLIENTDATA
       CLIENTDATAX                =  BAPI_CLIENTDATAX
       PLANTDATA                  =  BAPI_PLANTDATA
       PLANTDATAX                 =  BAPI_PLANTDATAX
       STORAGELOCATIONDATA        =  BAPI_STORAGELOCATIONDATA
       STORAGELOCATIONDATAX       =  BAPI_STORAGELOCATIONDATAX
       SALESDATA                  =  BAPI_SALESDATA
       SALESDATAX                 =  BAPI_SALESDATAX
    IMPORTING
       RETURN                     =  IT_RET
    TABLES
       MATERIALDESCRIPTION        = IT_MAKT
      UNITSOFMEASURE             =
      UNITSOFMEASUREX            =
      INTERNATIONALARTNOS        =
      MATERIALLONGTEXT           =
      TAXCLASSIFICATIONS         =
      RETURNMESSAGES             =
      PRTDATA                    =
      PRTDATAX                   =
      EXTENSIONIN                =
      EXTENSIONINX               =
    APPEND IT_RET.
    ENDFORM.                    " F_CALL_BAPI
    *&      Form  F_BAPI_COMMIT
          text
    -->  p1        text
    <--  p2        text
    FORM F_BAPI_COMMIT .
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      WAIT         =
    IMPORTING
      RETURN        =
    ENDFORM.                    " F_BAPI_COMMIT

  • Logic required for a Internal table  issue

    Hi All,
    I have 2 internal table. I need STLNR value to another internal table. Both having same field. But while reading from one internal table to another internal table using IDNRK key, One idnrk having 2 different stlnr value. But its taking only one. How to take both the values?
    The internal table value like below.
    it_stpo--> This is first table, Here one Idnrk having different stlnr value. I need the same in to next table. Here i read with idnrk field but its taking one stlnr value only into next table.
    How to change the logic ?
    Below is it_stpo table and next one is it_mbew_1
    it_stpo
    STLNR     IDNRK             MENGE
    17224     00439RM1     2.3
    17225     00439RM1     4.2
    172333     00849RM2     5.6
    172158     00432TM3     7.2
    152164     00583RM4     8.4
    176123     00583RM4     2.3
    it_mbew_1
    STLNR     IDNRK             STPRS
         00439RM1     111.22
         00439RM1     126.45
         00849RM2     3.3364
         00432TM3     15.5888
         00583RM4     0
         00583RM4     0.235
    My logic like below,
              SORT it_stpo BY idnrk.
              SORT it_mbew_1 BY matnr.
              LOOP AT it_mbew_1 INTO wa_mbew_1.
                READ TABLE it_stpo INTO wa_stpo WITH KEY idnrk = wa_mbew_1-matnr BINARY SEARCH.
                IF sy-subrc = 0.
                  wa_mbew_1-stlnr = wa_stpo-stlnr.
                  MODIFY it_mbew_1 FROM wa_mbew_1 TRANSPORTING stlnr WHERE matnr = wa_mbew_1-matnr.
                ENDIF.
              ENDLOOP.
    Kindly help us.
    Mohana

    Try below logic.
    add one more field to it_stpo flag type char01.
    update the field with value 'X'.
    SORT it_stpo BY idnrk.
              SORT it_mbew_1 BY matnr.
              LOOP AT it_mbew_1 INTO wa_mbew_1.
                CLEAR WA_STPO.
                READ TABLE it_stpo INTO wa_stpo WITH KEY idnrk = wa_mbew_1-matnr                                                                               
    flag = 'X'.
                if sy-subrc eq 0.
                         move ' ' to wa_stpo-flag.
                         modify it_stpo from wa_stpo index sy-tabix.
                          wa_mbew_1-stlnr = wa_stpo-stlnr.
                         MODIFY it_mbew_1 FROM wa_mbew_1 TRANSPORTING stlnr WHERE matnr = wa_mbew_1-matnr.
                 endif.
              ENDLOOP.
    Regards
    Vinod

  • Reg. internal table logic

    Hi,
    I have an internal table with 5 fields (Vbeln, A, B, C, D ) and records like this:
    Record1:
    Field vbeln (value is  6000000001), Field A (value is 2006), Field B (value is 1130), Field C (value is initial), Field D (value is initial)
    Record1:
    Field vbeln (value is  6000000001), Field A (value is initial), Field B (value is initial), Field C (value is 2005), Field D (value is 1134)
    Now whenever, Field A and Field B has values, field C and field D are initial and vice versa.
    I Want to get all of the field values in just one record like below when the key vbeln is same.:
    Field vbeln (value is  6000000001), Field A (value is 2006), Field B (value is 1130), Field C (value is 2005), Field D (value is 1134)
    I know I can create another internal table, copy the contents, use the looping logic and achieve the same but wondering if there is any better way of doing the same?
    Appreciate your input.
    Thanks!

    Hi,
    You need another internal tables. Please try this.
    SORT ITAB1.
    ITAB2[] = ITAB1[].
    LOOP AT ITAB1.
      LOOP AT ITAB2 WHERE ITAB2-VBELN EQ ITAB1-VBELN
                      AND ITAB2-DATE1 NE ITAB1-DATE1
                      AND ITAB2-TIME1 NE ITAB1-TIME1.
        ITAB3-VBELN = ITAB1-VBELN.
        ITAB3-DATE1 = ITAB1-DATE1.
        ITAB3-TIME1 = ITAB1-TIME1.
        ITAB3-DATE2 = ITAB2-DATE2.
        ITAB3-TIME2 = ITAB2-TIME2.
        APPEND ITAB3.
      ENDLOOP.
    ENDLOOP.
    Regards,
    Ferry Lianto

  • Regarding Internal table logic

    Hi,
    I have my internal table as follows:
    DATA: BEGIN OF I_DATA OCCURS 0,
            prgname TYPE SYST-REPID,
            matnr   TYPE mara-matnr,
            berid   TYPE mdma-berid,
          END OF I_DATA.
    Data that fills into can be as follows:
    Ex:
    PROGRAM1,1000,MRP1
    PROGRAM1,1000,MRP1
    PROGRAM1,2000,MRP1
    PROGRAM2,1000,MRP1
    PROGRAM2,1000,MRP1
    PROGRAM2,2000,MRP1
    PROGRAM3,1000,MRP1
    PROGRAM3,1000,MRP1
    PROGRAM3,2000,MRP1
    It can any order in above way.
    Then i will sort the above data as follows:
    SORT I_DATA BY prgname matnr berid.
    Now here my issue is:
    DATA: t_objtxt     LIKE solisti1   OCCURS 0  WITH HEADER LINE.
    I need to push the above internal table data into T_OBJTXT internal table as follows:
    It should first Display program Name as Program Name: Program3, Then column heading MATNR, BERID below it and data of that program[1st] below them till all the 1st program's data finished. Whenever MATNR value changes in this program list i need to print an ***** like line. TO indicate all the materials printed.
    When 2nd program comes again i have to write Program Name: Program2, Then column heading MATNR, BERID below it and data of that program[1st] below them till all the 1st program's data finished. Whenever MATNR value changes in this program list i need to print an ***** like line. TO indicate all the materials printed.
    When 3nd program comes again i have to write Program Name: Program3, Then column heading MATNR, BERID below it and data of that program[1st] below them till all the 1st program's data finished. Whenever MATNR value changes in this program list i need to print an ***** like line. TO indicate all the materials printed.
    Etc. Same process we need to follow.
    The final out put should be as below:
    PROGRAM NAME : PROGRAM1
    MATNR, BERID
    1000,MRP!
    1000,MRP1
    2000,MRP1
    PROGRAM NAME : PROGRAM2
    MATNR, BERID
    1000,MRP!
    1000,MRP1
    2000,MRP1
    PROGRAM NAME : PROGRAM3
    MATNR, BERID
    1000,MRP!
    1000,MRP1
    2000,MRP1
    Like wise o/p need to be send to I_OBJTXT and to email.
    <b>The logic i have written is as follows:</b>
      LOOP AT I__DATA.
        AT NEW PRGNAME.
          MOVE '*****************************************' TO t_objtxt-line.
          APPEND t_objtxt.
          CLEAR t_objtxt.
          CONCATENATE t_objtxt-line 'PROGRAM NAME : '
                      I_DATA-PRGNAME
                      INTO t_objtxt-line.
          APPEND t_objtxt.
          CLEAR t_objtxt.
          MOVE '*****************************************' TO t_objtxt-line.
          APPEND t_objtxt.
          CLEAR t_objtxt.
          CONCATENATE TEXT-024 " Material
                      TEXT-025              " MRP
                      INTO t_objtxt-line
                      SEPARATED BY C_COMMA.
          APPEND t_objtxt.
          CLEAR t_objtxt.
          MOVE '-----------------------------------------' TO t_objtxt-line.
          CONCATENATE t_objtxt-line '------------------' INTO t_objtxt-line.
          APPEND t_objtxt.
          CLEAR t_objtxt.
        ENDAT.
    *    MOVE '' TO t_objtxt-line.
    *    APPEND t_objtxt.
    *    CLEAR t_objtxt.
        CONCATENATE I_DATA-MATNR
                    I_DATA-BERID
                    INTO t_objtxt-line
                    SEPARATED BY C_COMMA.
        APPEND t_objtxt.
        CLEAR t_objtxt.
        AT END OF MATNR.
          MOVE '' TO t_objtxt-line.
          APPEND t_objtxt.
          CLEAR t_objtxt.
          MOVE '*****************************************' TO t_objtxt-line.
          CONCATENATE t_objtxt-line '******************' INTO t_objtxt-line.
          CONCATENATE t_objtxt-line '******************' INTO t_objtxt-line.
          APPEND t_objtxt.
          CLEAR t_objtxt.
        ENDAT.
      ENDLOOP.
    The above logic is not working correctly.
    Can anybody give me correct logic for the same.
    Thanks in advance.
    Thanks,
    Deep.

    Can you paste the total code.
    santhosh

  • Internal table logic required

    Hi ,
    I have two internal tables having with different structures . Finally I need to pass data to final internal table.
    In runtime we have data in only one table.  The final internal table should take either internal1, or internal table 2.
    it_final_data[] = it_first_data[].
    or
    it_final_data[] = it_sec_data[].
    i have to one generic include , it will understands the IT_final_data internal table only.
    please help me.
    regards,
    Ajay

    Hi Ajay,
         Build your final internal table with all the fields from first and second internal table. Use the below logic to move the data to the final internal table depending on the internal table data which you want to display.
    IF not it_first_data[] is initial.
      loop at it_first_data.
        move-corresponding it_frist_data to it_final_data.
        append it_final_data.
    endloop.
    else.
       loop at it_second_data.
        move-corresponding it_second_data to it_final_data.
        append it_final_data.
      endloop.
    endif.
    Hope this works for you.
    Regards,
    Jayaram

Maybe you are looking for