Issue in Internal Table for calculating MAX value

Hi Abapers,
I have internal table with data as follows:
                     Materail                               Currency      Quantity    Dominant_Currency
1     000000000007001896     GBP     396
2     000000000007001896     EUR     25
3     000000000007001310     USD      7
4     000000000007001310     GBP     646
5     000000000007001310     EUR     195
6     000000000007000949     GBP     947
7     000000000007000949     EUR     117
Now I have to find out the max quantity for each materail and currency against max quantity which will be put in the dominat currency fields of Internal Table.
Eg: For material 000000000007001896, 396 is the max quantity and Currency for this is GBP so dominant currency will be GBP for first 2 records.
Similarly 646 is max for 000000000007001310 therefore GBP will be dominant curr for the records containg material 000000000007001310
Please solve the issue.
Regards,
Rahul Sinha

lv_quantity --> quantity parameter
sort itab by matnr quantity
loop at itab.
at new material.
clear lv_quantity.
endat,
if itab-quantity > lv_quantity.
  lv_quantity = itab-quantity.
  itab-dominant_curr = itab-curr.
  modify itab transporting dominant_curr where material = itab-material.
endif.
"please write  modify statement with some logic..so that it is called once for one item
endloop.
if you find any issue revert back.

Similar Messages

  • Number of entries in the internal table for perticular field value

    hi All,
    Is this possible to get the count of records from the internal table for a perticular field value.
    currently my requirement is to get the entries from the internal table which does not have two records for perticular field value (say a = 123) whose status is active (say b = 'X').
    also suggets should use LOOP or DELETE or DESCRIBE for a internal table to ful fill this requirement.
    Thanks in advance.
    Pradeep

    Try like this..
    Create another table itab2 with same structure as itab1 & move the contents of itab1 to itab2
    ITAB2[] = ITAB1[].
    Then delete entries from itab2
    Delete itab2 whete a = '123' and b = 'X'
    Then use Describe statement to get the no of entries
    Describe table itab2 lines v_lines.
    Hope this helps...

  • Select on MARA resulting into # values in internal table for one field

    Hi Team,
    I have written a SELECT statement on MARA table as below.
    TRY.
            SELECT matnr zzwftag FROM mara CLIENT SPECIFIED
              INTO CORRESPONDING FIELDS OF TABLE gt_mara WHERE
              mandt = sy-mandt AND
              zzwftag NE space
              AND zzwftag IS NOT NULL
              AND zzwftag NE '#'
              AND zzwftag NE '%#%'
              AND zzwftag NE '  '
              AND zzwftag NOT LIKE '%/%'(012).
          CATCH cx_sy_dynamic_osql_error.
            MESSAGE 'Error While Fetching Data from MARA'(044) TYPE 'S'(040)  DISPLAY LIKE 'W'(041).
        ENDTRY.
        IF NOT gt_mara[] IS INITIAL.
          DELETE gt_mara[] WHERE zzwftag EQ '#'
          OR zzwftag IS INITIAL
          OR zzwftag EQ space
          OR zzwftag EQ ' '.
        ENDIF.
    Observations: 1. In
    the resulting internal table I am seeing '#' values for fields zzwftag which are actually empty when I see the record in SE11 in MARA(ALV display). It shows '#' in it in SE16 display(We can choose User parameters and hence mode of display in SE11)
    The requirement is to avoid those records where zzwftag is initial i.e. blank. I tried to delete invalid records but to no avail.
    Please suggest any way where I can get the Select correct.
    Regards,
    Amit

    Please do not use so many not conditions in one query....
    Using so many negative conditions results in bad data.
    Instead use delete statements later this would not confuse the system.
    Also if you are using sy-mandt then i think you should not use client specified system will take care of it.
    TRY.
    SELECT matnr zzwftag FROM mara CLIENT SPECIFIED
    INTO CORRESPONDING FIELDS OF TABLE gt_mara WHERE
    mandt = sy-mandt AND
    zzwftag NE space.
    CATCH cx_sy_dynamic_osql_error.
    MESSAGE 'Error While Fetching Data from MARA'(044) TYPE 'S'(040) DISPLAY LIKE 'W'(041).
    ENDTRY.
    IF NOT gt_mara[] IS INITIAL.
    DELETE gt_mara[] WHERE zzwftag EQ '#'
    OR zzwftag IS INITIAL
    OR zzwftag EQ space
    OR zzwftag EQ ' '.
    delete gt_mara[] where zzwflag eq '%#%'.
    ENDIF.

  • Issue with Internal Table

    Hi All,
    I have defined an internal table 'with occurs 0'.
    While debuggining, i am observing that only 50,000 lines are getting populated in that internal table.
    How to increase the capacity of the internal table, so that it can hold more number of lines?
    Regards
    Pavan

    I would like to explaing you all about this issue.
    I have defined an internal table as follows...
    data:  IT_CATSDB       TYPE BAPICATS2 OCCURS 0 WITH HEADER LINE.
    I have used a BAPI called "BAPI_CATIMESHEETRECORD_GETLIST" which will retirieve the Timesheet details of all employees within a given date range.
    Now, the number of entries that we got from this BAPI are stored in the internal table it_catsdb.
    I have observed that this internal table is holding max of 50k lines.
    If i check the database table (CATSDB) for the same conditions in SE11, i am able to get around 1L lines.
    Hence my report is showing incorrect output.
    Kindly help me out with some logic, so that this internal table can hold as much as data possible without any restriction.....
    Regards
    Pavan

  • Filtering internal table using select-option values

    Hi,
    I got an internal table with select-option values. for eg.  it_perno with the values  I  BT    000160    000170.
    Now i got another second internal table which is have the person number. Now i need to filter this second internal table based on the values from the select option table. my question is
    i can collect all the values from 160 to 170 in a separate table by looping over the select option table. and then based on the values filter the second internal table person number.
    But what would be the case if the select option contains both intervals and multiple options. For eg.
    I BT 000160      000170.
    I EQ 000185.
    So can you suggest any good solution, that based on this select option table i need to filter the second internal table Person number.
    Thanks in advance.
    Regards,
    anbu.

    Hi,
    Can you not use the select-options in the Select query while populating the internal table.
    SELECT pernr FROM pa0000 INTO it_tab WHERE pernr IN s_pernr.
    If you cannot do this and you do not want to delete the unwanted entries, then you can use the WHERE clause in the LOOP statement to process the specific entries required:
    LOOP AT it_tab INTO wa_tab WHERE pernr IN s_pernr.
    Regards,
    Aparna Alashe.

  • Table for po effective value

    Hi,
    I need to develop a purchase order report, so I need the following
    gross price  : 100
    fright        : 10
    insurance : 10
    my net value is : 100 rs
    Effective value : 120 rs
    Where can I find ( table) for this effective value
    fright and insurance I can find from KONV table, But I need effective value or total value
    Thanks
    Srinivas

    PO Header: EKKO
               field: EKKO-KNUMV (number of condition document)
    PO Item: EKPO
               field: EKPO-NETWR (net value in PO currency)
    Conditions: KONV
               field: KONV-KNUMV = EKKO-KNUMV
               for PO item conditions, item number of condition document = item number of PO
               for PO header conditions, item number of condition document = 0000
    Subtotals in the pricing procedure are calculated and not stored in any KONV.
    PO header Net Price = sum of all EKPO-NETWR for all the items.
    Hope this helps.

  • How to Read the internal table for the data download from the spool

    HI all,
    I have one issue regarding the spool ,we are getting the correct output as per requirement of  user but when we send the same to the user in pdf format they did notget the same.
    they are telling that the due date is missing from the pdf.
    Please advice me how to track the internal  table for the spool data converted intopdf in a readable format.
    the FM used for the above task is : 
    call function 'CONVERT_OTFSPOOLJOB_2_PDF'
    Please reply if any one worked on the same.
    Thanks in advance.
    Gaurav,

    Hi Wang,
    Please let me know how you solved your question.
    Points will be rewarded.
    Thanks,
    Arun.

  • How to create internal table for a structure in BSP

    hi ,
    I have created a Structure in BSP.I want to create an internal table for that Structure. But in my coding ie.
    <% data: begin of itab_1 .
                     include type zuvendstr.
                     data:end of itab_1.
                     data wa_str like line of itab_1.
                     loop at itab_1 into wa_str. %>
                    <tr>
                     <td><%=wa_str-name%> </td>
                           <%endloop.%>
    In this zuvendstr is Structure ,wa_str is workarea and itab_1 is an Internal table.But it is showinng an error that itab_1 is unknown.But we cannot define internal tables for an Structure in Page Attributes.So,please resolve how to create internal table for Structure in BSPS

    Hi,
    You can define itab_1 like this (assuming zuvendstr is a structure type):
    DATA: itab_1 TYPE TABLE OF zuvendstr.
    Regards,
    Tanguy

  • To count number of records in an internal table for a condition

    Hello All,
            I want to count number of records in an internal table for a condition.
    For e.g. -- I have one internal table IT which having fields F1, F2, F3, F4, F5.
                     Now, I want number of records in itnternal table IT where F1 = 'ABC'.
    Is it possible to do..?? If yes, then how.??
    Thanks in advance...!!
    Regards,
    Poonam.

    Hi,
    If you mean an internal table, there are a few ways to do this.
    1 One would be to loop over the table with a WHERE clause and increment a counter.
    data: lv_counter type i.
    clear lv_counter.
    loop at itab where fld1 = 'ABC'.
    lv_counter = lv_counter + 1.
    endloop.
    lv_counter now has the number of rows per the condiction.
    2  Well, you may want to try this as well, and compare to the LOOP way. Not sure what kind of overhead you may get doing this way. Here ITAB is our main internal table, and ITAB_TMP is a copy of it. Again I think there may be some overhead in doing the copy. Next, delete out all records which are the reverse of your condition. Then whatever is left is the rows that you want to count. Then simply do a LINES operator on the internal table, passing the number of lines to LV_COUNT.
    data: itab type table of ttab.
    data: itab_tmp type table of ttab.
    itab_tmp[] = itab[].
    delete table itab_tmp where fld1  'ABC'.
    lv_count = lines( itab_tmp ).
    Thanks & Regards,
    ShreeMohan

  • Fill Internal Table for Table Header EQUI - Long Time

    Good morning,
    I have installed DMIS (2006_1_620) and DMIS_CNT (2006_1_620), both at the level of SP = 13.
    I am running the subactivity "Fill Internal Table for Table Header EQUI" and have 1 day + 10 hours and continue working.
    Also note that the table CNVTDMS_05_equi  is increased million in millions and now has 6 million records.
    It is normal to take a long time? (EQUI table has 240 million records and therefore will take many days).
    Any suggestions?
    Thanks,
    Hugo

    Hello Hugo,
    I know this is old , but did you ever find a solution to this.  I am having the same problem.  I considered adding an index to table QMIH, with Keys MANDT and BEQUI.
    I also only have one bckgrd proc running in sender systems with this statement when I drill in using SM50:
    SELECT
    /*+
      FIRST_ROWS (1)
    FROM
      "QMIH"
    WHERE
      "MANDT"=:A0 AND "BEQUI"=:A1 AND ROWNUM <=:A2 #
    This has been running for over 8hrs now.
    Any thoughts?
    Thanks,
    NICK

  • Dynamic Internal Table for reading data from external file

    Hello All,
    The task was to create a internal table with dynamic columns,
    Actually this is my first task in the WebAS 6.20, my program is based on input file provided by user with certain effort. this file can have different effort for a one yr to five year frame..
    I needed to read the raw data from file, based on months create a internal table to hold the data, after this i need to validate the data...
    I have browsed thru dynamic internal table topic, but couldn't find any dynamic appending structure, the dynamic structure would contains 12 month fileds.
    can any one help me in getting my task completed..
    Thanks
    Kumar

    Hi,
    I see that you posted the same question a couple of days ago at Dynamic Internal Table for reading data from external file Didn't Charles's response address your problem?
    Regards

  • Read Internal Table based on Multiple Values for Key Field

    Hi Gurus,
    i have one query can you tell me how read an internal table it_kna1 for multiple values of land1 DE US IND etc.
    i had tried as below but i could not can you try and let me knwo at the earliest.
    here i want read the values with DE or US and want further prosess them.
    REPORT  YC001.
    tables kna1.
    select-options: cust for kna1-kunnr.
    data: begin of it_kna1 occurs 0,
            kunnr like kna1-kunnr,
            name1 like kna1-name1,
            land1 like kna1-land1,
            end of it_kna1.
    select kunnr name1 land1 into table it_kna1 from kna1 where kunnr in cust.
    read table it_kna1 with key land1 = ( 'DE' OR 'US' ) .
    can anybody suggest me some solution.
    Thanks,
    Jeevi.

    This should be what you need:
    REPORT ztest NO STANDARD PAGE HEADING LINE-SIZE 80 MESSAGE-ID 00.
    TABLES kna1.
    SELECT-OPTIONS: cust FOR kna1-kunnr.
    DATA: BEGIN OF it_kna1 OCCURS 0,
            kunnr LIKE kna1-kunnr,
            name1 LIKE kna1-name1,
            land1 LIKE kna1-land1,
          END OF it_kna1.
    DATA: itab_index LIKE sy-tabix.
    SELECT kunnr name1 land1
      INTO TABLE it_kna1
      FROM kna1
      WHERE kunnr IN cust.
    SORT it_kna1 BY land1.
    READ TABLE it_kna1 WITH KEY
      land1 = 'DE'
      BINARY SEARCH.
    itab_index = sy-tabix.
    WHILE sy-subrc = 0.
      itab_index = itab_index + 1.
      WRITE: /001 it_kna1-kunnr, it_kna1-land1, it_kna1-name1.
      READ TABLE it_kna1 INDEX itab_index.
      IF it_kna1-land1 <> 'DE'.
        sy-subrc = 99.
      ENDIF.
    ENDWHILE.
    SKIP 1.
    READ TABLE it_kna1 WITH KEY
      land1 = 'US'
      BINARY SEARCH.
    itab_index = sy-tabix.
    WHILE sy-subrc = 0.
      itab_index = itab_index + 1.
      WRITE: /001 it_kna1-kunnr, it_kna1-land1, it_kna1-name1.
      READ TABLE it_kna1 INDEX itab_index.
      IF it_kna1-land1 <> 'US'.
        sy-subrc = 99.
      ENDIF.
    ENDWHILE.
    Rob

  • Just need the record from the right (many) table with the max value for the Record on the left (one) side table

    SELECT
      ADHOC.ATS_ESH.Entry_Num
      ,ADHOC.ATS_ESH.Importer
      ,ADHOC.ATS_ESH.Version AS [ATS_ESH Version]
      ,ADHOC.ATS_ESL.Version AS [ATS_ESL Version]
    FROM
      ADHOC.ATS_ESH
      INNER JOIN ADHOC.ATS_ESL
        ON ADHOC.ATS_ESH.Customs_Entry_Num = ADHOC.ATS_ESL.Customs_Entry_Num
    I just need to see the MAXIMUM version number in the ESL table for each Entry_Num in the ESH table. ESH is the one side, ESL is the MANY side.

    Do you understand what this query is doing? Did you check the blogs I pointed you to?
    The query I provided gets the latest ESL version for each custom number. So, if max ESL version is higher than ESH version, it's just a coincidence. If you only want to see rows where versions do not match, just add an extra where condition, e.g.
    SELECT * FROM cte WHERE Rn = 1
    AND  [ATS_ESH
    Version] <>  [ATS_ESL
    Version]
    BTW, what is the type of these version
    columns and what kind of data in them? If they are character columns, sorting them in DESC order will not necessary return the latest version. Can you show some samples of the data in these two columns?
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • Issue regarding internal tables

    Dear all,
    My issue is that , I need to enter data into a single internal table by fetching data from two sap tables using two different selct quries. I should not use joins or for all entries. And display the internal table data in the list.
    Problem am facing is only one select query is geeting fetched and the other table data in not in the list.
    Pleas provide the possible solutions.
    Thanks & Regards,
    Madhavi.M

    DATA: BEGIN OF itab1 OCCURS 0,
          qmnum LIKE qmel-qmnum,
          qmtxt LIKE qmel-qmtxt,
          indtx LIKE qmel-indtx,
          qmdat LIKE qmel-qmdat,
          ltrmn LIKE qmel-ltrmn,
          priok LIKE qmel-priok,
          aufnr LIKE qmel-aufnr,
          bezdt LIKE qmel-bezdt,
          qmnam LIKE qmel-qmnam,
          qmart LIKE qmel-qmart,
          END OF itab1.
    DATA: BEGIN OF itab2 OCCURS 0,
          qmnum LIKE qmih-qmnum,
          btpln LIKE qmih-btpln,
          ingrp LIKE qmih-ingrp,
          END OF itab2.
    DATA : itab3 TYPE TABLE OF z_notif WITH HEADER LINE.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.
    SELECT-OPTIONS : notnum FOR qmel-qmnum OBLIGATORY,
                     notype FOR qmel-qmart,
                     floc FOR qmih-btpln,
                     name FOR qmel-qmnam.
    SELECTION-SCREEN END OF BLOCK b1.
    START-OF-SELECTION.
    To fetch the values in the internal table ****************
    from ztable corresponding to the entries made *************
    by the user in the selection screen ******************
    SELECT qmnum qmtxt indtx qmdat ltrmn priok aufnr bezdt qmnam qmart INTO
    TABLE itab1 FROM qmel WHERE qmnum IN notnum
    AND qmart IN notype AND qmnam IN name.
    SELECT qmnum btpln ingrp INTO TABLE itab2 FROM qmih FOR ALL ENTRIES IN
    itab1 WHERE qmnum = itab1-qmnum AND btpln IN floc.
    To move the contents of ITAB1 to ITAB3 ***************
        LOOP AT itab1.
          itab3-qmnum = itab1-qmnum.
          itab3-qmtxt = itab1-qmtxt.
          itab3-indtx = itab1-indtx.
          itab3-qmdat = itab1-qmdat.
          itab3-ltrmn = itab1-ltrmn.
          itab3-priok = itab1-priok.
          itab3-aufnr = itab1-aufnr.
          itab3-bezdt = itab1-bezdt.
          itab3-qmnam = itab1-qmnam.
          itab3-qmart = itab1-qmart.
          READ TABLE itab2 WITH KEY qmnum = itab1-qmnum.
    To move the contents of ITAB2 to ITAB3 ***************
          itab3-btpln = itab2-btpln.
          itab3-ingrp = itab2-ingrp.
          APPEND itab3.
        ENDLOOP.
    have a look at this example this may help you.....
    reward if helpful.....

  • This is really a SQL question. How to get a record for the max value

    I have a table ZTX with the following fields and values
    VBELN  POSNR SEQNR DESCRIPTION
    3001             10   001  Desc1
    3001             10   002  Desc2
    3001             10   003  Desc3
    I want to create a query so that I can join tables VBAK-VBELN, and VBAP and ZTX. So that I only get the row of ZTX which has max (SEQNR) i.e 003 in this case. How can I write the SQL statement. Is there a way to write a single SQL statement which can retrieve from all three table VBAK, VBAP and ZTX maybe with a subquery or do I really have to first take the results of VBAK and VBAP join into internal table then fire query on ZTX.
    Thanks for reading

    Something like this
    Select * into table my_table from ztx as z
    join vbak as b on b~vbeln = z~vbeln
    join vbap as p on p~vbeln = z~vbeln " maybe posnr also?
    where
    z~seqnr = ( select max( seqnr ) from ztx where vbeln = z~vbeln ).

Maybe you are looking for

  • Reciever File Adapter - Temp File Name Scheme using Variable Substitution

    How can I create a temporary file that uses variable substitution?  We are having a problem with files merging when we write files using the "Use Temporary File" setting on the FIle Adapter.  So two independent files are merging into a single file. 

  • [Solved by adding GQview]Is Feh not capable of opening svg files...?

    I have installed Feh from the community repos, along with imlib2. according to the official website, feh can open SVG files, but I get an error... feh WARNING: /home/jaydoc/archlinux-artwork-1.1/logos/archlinux-grad1-dark.svg - No Imlib2 loader for t

  • Object serialized Problem

    Hi there, I got one window mapped to a object ( say ObjectA ). The window contains textbox, droplist. I then serialized the object (ObjectA) to a file and read it back to memory. Everything seems fine except the droplist shown the wrong data. e.g. Th

  • Invisible Library file

    I was archiving some old images, bringing them into a new Aperture Library. I had created the library on an external drive, but apparently it still thought it was on my internal drive. After a few hours of work, Aperture gave a warning that it was ou

  • How to create shared photostream and let others add photos

    Creating a Photostream that allows others to add images can be done on my iOS7 devices, but it seems Aperture is missing the option to do it on the Mac. Am I missing something?