Link between SD invoice item and corresponding accounting document item

Hi,
I have a problem regarding the link between the items of an SD invoice ( or
credit note ) and those of the corresponding accounting document. There's a
custom report which extracts information about each credit/debit note
produced within a certain period. This program has recently failed due to a
particular case: a credit note was generated starting by two note requests;
in other terms, cardinality: 1:N exists between the credit note and the
request document. Currently, the program generates duplicated records in
this case, because of the following schema:
-> main loop on VBAK data ( request document header data )
   -> inner loop on BSEG data ( accounting document items );
our current access criteria in reading tb_bseg is only:
... where tb_bseg-belnr = tb_vbrk-vbeln.
Providing that tb_vbrk-vbeln doesn't differ and that both tb_vbak and tb_bseg
contain two records ( the two requests the first and the two accounting
document items the second ), the program fails as follows:
° first request  -> two lines
° second request -> two lines.
Is there any way to link each invoice item with the corresponding credit
note item?
Thanks in advance to all of you.
Adrian.

Hi,
I have a problem regarding the link between the items of an SD invoice ( or
credit note ) and those of the corresponding accounting document. There's a
custom report which extracts information about each credit/debit note
produced within a certain period. This program has recently failed due to a
particular case: a credit note was generated starting by two note requests;
in other terms, cardinality: 1:N exists between the credit note and the
request document. Currently, the program generates duplicated records in
this case, because of the following schema:
-> main loop on VBAK data ( request document header data )
   -> inner loop on BSEG data ( accounting document items );
our current access criteria in reading tb_bseg is only:
... where tb_bseg-belnr = tb_vbrk-vbeln.
Providing that tb_vbrk-vbeln doesn't differ and that both tb_vbak and tb_bseg
contain two records ( the two requests the first and the two accounting
document items the second ), the program fails as follows:
° first request  -> two lines
° second request -> two lines.
Is there any way to link each invoice item with the corresponding credit
note item?
Thanks in advance to all of you.
Adrian.

Similar Messages

  • Link between the Schedule Lines and the GR document

    Hi
    I would like to find the link between the Schedule Lines (of Scheduling Agreement) and the GR document. i.e. which GR has been made against which Schedule Line. I have checked the tables EKET, EKBE, MSEG but there is no link with the Schedule Line, I found the link only with the item number there.
    Thanks
    Prashanth

    Hi
    At the time of posting the GR for a SA you will be not posting this with reference to the Schedule line of the SA item. So system will always update the GR document against the SA item and update qty on the schedule line.
    May be this is the reason we donot have any direct relation ship to material document and Scheclue line
    Thanks & Regards
    Kishore

  • Table display link between PSA Table name and corresponding Datasource

    Hi Colleagues,
    Is there a table from which one we can see the datasource corresponding to the PSA table name ?
    Thanks

    RSDSSEG
    you still have to give the version number... which can be 000 .. 001 or something

  • Is there a link between the Journal tables and the Marketing Document tables?

    Hi Everyone,
    Is there a link back from the Journal Tables (e.g.: OJDT and / or JDT1) to the Marketing Documents tables (e.g.: OINV and / or INV1)?
    If there is a link can you please let me know what it is?
    Kind Regards,
    David

    David..
    Try This
    Select T1.RefDate,
    Case
    When T1.TransType=13 Then 'Invoice'
    When T1.TransType=14 Then 'A/R Credit Memo'
    When T1.TransType=15 Then 'Delivery Note'
    When T1.TransType=16 Then 'Delivery Return'
    When T1.TransType=162 Then 'Stock Revaluation'
    When T1.TransType=18 Then 'Purchase Bill'
    When T1.TransType=19 Then 'A/P Credit Memo'
    When T1.TransType=20 Then 'GRPO'
    When T1.TransType=202 Then 'Work Order'
    When T1.TransType=21 Then 'Goods Return'
    When T1.TransType=24 Then 'Incoming Payment'
    When T1.TransType=30 Then 'Journal'
    When T1.TransType=46 Then 'Outgoing Payment'
    When T1.TransType=59 Then 'Goods Receipt'
    When T1.TransType=60 Then 'Goods Issue'
    When T1.TransType=67 Then 'Stock Transfer'
    Else T1.TransType
    End [TransType],
    T1.TransId,
    Case
    -- Sales A/R
    When T1.TransType = 13 Then (Select isnull(Comments, '') From OINV Where DocNum = T1.BaseRef and CardCode = T1.ShortName) -- Invoice
    When T1.TransType = 14 Then (Select isnull(Comments, '') From ORIN Where DocNum = T1.BaseRef and CardCode = T1.ShortName) -- A/R Credit Memo
    When T1.TransType = 15 Then (Select isnull(Comments, '') From ODLN Where DocNum = T1.BaseRef and CardCode = T1.ShortName) -- Delivery
    When T1.TransType = 16 Then (Select isnull(Comments, '') From ORDN Where DocNum = T1.BaseRef and CardCode = T1.ShortName) -- Delivery Return
    -- Purchase A/P
    When T1.TransType = 18 Then (Select isnull(Comments, '') From OPCH Where DocNum = T1.BaseRef and CardCode = T1.ShortName) -- Purchase Bill
    When T1.TransType = 19 Then (Select isnull(Comments, '') From ORPC Where DocNum = T1.BaseRef and CardCode = T1.ShortName) -- A/P Credit Memo
    When T1.TransType = 20 Then (Select isnull(Comments, '') From OPDN Where DocNum = T1.BaseRef and CardCode = T1.ShortName) -- GRPO
    When T1.TransType = 21 Then (Select isnull(Comments, '') From ORPD Where DocNum = T1.BaseRef and CardCode = T1.ShortName) -- Goods Return
    -- Production
    When T1.TransType = 202 Then (Select isnull(Comments,'') From OWOR Where DocNum = T1.BaseRef and PostDate = T1.RefDate) -- Work Order
    -- Banking
    When T1.TransType = 24 Then (Select isnull(Comments, '') From ORCT Where DocNum = T1.BaseRef and CardCode = T1.ShortName) -- Incoming Payment
    When T1.TransType = 46 Then (Select isnull(Comments, '') From OVPM Where DocNum = T1.BaseRef and CardCode = T1.ShortName) -- Outgoing Payment
    When T1.TransType = 30 Then (Select ISNULL(LineMemo, '') From JDT1 Where Ref1 = T1.Ref1 and ShortName = T1.ShortName) --  Journal
    -- Inventory
    When T1.TransType = 59 Then (Select ISNULL(Comments, '') From OIGE Where DocNum = T1.Ref1 and DocDate = T1.RefDate) -- Goods Receipt
    When T1.TransType = 60 Then (Select ISNULL(Comments, '') From OIGN Where DocNum = T1.Ref1 and DocDate = T1.RefDate) -- Goods Issue
    When T1.TransType = 67 Then (Select ISNULL(Comments, '') From OWTR Where DocNum = T1.Ref1 and DocDate = T1.RefDate) -- Stock Transfer
    When T1.TransType = 162 Then (Select ISNULL(Comments, '') From OMRV Where DocNum = T1.Ref1 and DocDate = T1.RefDate) -- Stock Revaluation
    Else ''
    End [Remarks],
    T1.LineMemo,
    Case
    When exists (Select AcctCode From OACT Where AcctCode = T1.ContraAct)
    Then (Select AcctName From OACT Where AcctCode = T1.ContraAct)
    else (Select CardName From OCRD Where CardCode = T1.ContraAct)
    End [Account],
    Case
    When T1.Debit=0.0
    Then 0.0
    Else T1.Debit
    End Debit,
    Case
    When T1.Credit=0.0
      Then 0.0
    Else T1.Credit
    End Credit
    From JDT1 T1
    Where T1.TransType <> -3
    And T1.RefDate Between @FromDate and @ToDate
    And T1.ShortName = @Account
    Order By T1.RefDate,
    T1.TransId
    Regards
    Kennedy

  • Whats the link between Migo ( Material Doc no ) & resp Accounting doc no

    In order to generate one development in MM. I need to know Link between Material Doc number ( MIGO ) transaction & Accounting document generated for that particular Material doc number which we browse thru Follow on Doc.
    In case the Number range for both is same the solution is easy but we have No ranges for both these are different.
    Can experts help me to identify link at Table / Field level which is critical for our Abap Development.
    Regards
    Umesh Bagul

    Hi Umesh,
    The link between the Material document & Accounting document is  Movement type.
    Goods movement such as Goods receipt /Goods Issue /Stock transfer is always based on the type of " Movement type " which we are using and 2ndly the type of material that we are procuring and receiving or issuing or posting the goods movements. Because based on the Material only the properties of material depends.  For eg. for Raw material stock updation is possible for Quantity & also for Value.  That means whenever you receive the goods of Raw material agains the external vendor (these goods are received against the PO with r.to. 101 Mvt type), then both Quantity updated (for this Evidence is Material document) and Value is also gets updated (for this Evidence is Accounting document), when you receive the whole stock into Unrestricted use stock /storage location. 
    Note::  The movement type is linked with Value string:   101 - Stock updation - by Quantity -  by Value -  Stock indicator - account modifier with the help of Valuation class - A/c category reference - Material type.
    For example: If its receiving of goods against PO is through MIGO using 101 Mvt type.
    and also 
    Simply can say that, Movement type plays the majour role in every goods movements and further that shows with the evidnece of material document and subsequent accounting document depending upon the movement type. And this is the link between the Material document and accounting document.
    Hope that clarifies you,
    Regards,
    Sapsrin

  • Link between Invoice document items and Accounting document items

    Hello, Colleagues.
    Can you help me, please. I don't solved next problem. I should associate Invoice document (Create with MIRO) items from tab "PO reference" with items from tab "G/L account" or with tax items Follow-on accounting document. Invoice document can contain items with amount equals 0 and this items don't add to the tab "G/L account" and to the items accounting document. So Invoice document can contain items with material code greate than one.
    Or link between RSEG <-> BSEG or link between RSEG <-> RBCO.
    Thank you.

    Hi ,
    U can refer the  VBRP - vbeln to BSEG-REBZG and get REBZZ (Invoice line item).
    thanks
    Shambhu

  • TABLE link between RPM Item and corresponding cProject

    Is there a table that shows exact link between RPM Item and corresponding cProject that is created automatically?
    Thanks

    use Table RPM_OBJ_LINK
    select on
    PROJECT_GUID= Item GUID
    OBJECT_TYPE = '0INMCPROJECT'
    Get cProject GUID from OBJECT_KEY.

  • Link between invoice no and payment clearing document no

    Hi sap gurus,
    in a reoprt i have to show the payment receive date against the invoice no. i can have the invoice no by customer no (KUNNR) and date range. now i am facing problem how to link invoice document no with payment clearing document no. Because while receiving payment from customer (t code F-28) we are receiving against a invoice. But i checked in BSEG,BSID BSAD but nowhere i was able to track the linkage. Please help.
    regards,
    BKR

    In billing document at header level,  you can see two fields, viz.
    a)  XBLNR   Reference Document Number  and
    b)  ZUONR   Assignment number
    These two fields you can see in FBL5N.  Whatever copy control you set in VTFL at header level for these two fields, based on that values will be populated in billing document which will then be passed on to FI just for information.
    But these two fields are not stored in any table but in structure.  However, you can check in BKPF with field XBLNR which will have link between VBRK (billing document ) and BKPF (Accounting document)
    thanks
    G. Lakshmipathi

  • Link between Customer Purchase Order and Accounting Document Number

    Hello all,
    is there a table in SAP that contains the purchase order number of the customer and the Accounting Document Number (belnr)?
    thanks in advance
    Anne

    Do this:
    SELECT awtyp awkey
      FROM bkpf
      INTO CORRESPONDING FIELDS OF bkpf
      WHERE bukrs = bsis-bukrs
        AND belnr = bsis-belnr
        AND gjahr = bsis-gjahr.
    ENDSELECT.
    This should give you SD billing document information.
    Rob

  • Link between schedule Line Number and Delivery

    Is there a link between Schedule line Number and Delivery number ?
    Eg. Line item 10 with quantity 100. 
    has 5 schedule lines..with 5 different delivery dates.
    1 .  quanity 40
    2.   quantity 30
    3.   quantity 20
    4.   quanity  6
    5    quantity  4
    For schedule line 1, 2 deliveries were created,
    one      with quantity 20
    another with quantity 15
    quantity 5 is still not delivered.
    also schedule lines 2,3,4 and 5 are fully delivered.
    Is there any table, FM etc in SAP which will give me the link between the schedule line and delivery number ?
    Total deliveries created : 6. - But which delivery corresponds to which schedule line ?
    Please dont tell me to look VGBEL and VGPOS.. that will just give line item number 10.. I need to get the schedule line number.
    Also, RV_SCHEDULE_CHECK_DELIVERIES --> will give me the delivered quantity against each schedule line.
    My purpose is to create an ontime delivery report .
    a report which list each schedule lines, and tell, how many shipments were late/ontime/early etc..
    and for Late ones, how many days late has to be found.
    this is where i need the delivery.
    No. Of days Late = Actual GI Date - Planned GI Date.
    Actual GI date is in the delivery.
    Any suggestions ?
    Thank you in advance.

    Hi,
    Check in the below link.
    relation between VBEP-ETENR and LIKP-VBELN
    Thanks,
    Sree.

  • FAGLB03 and GL Account Line Item Display  not tally

    Hi SAP Guru,
    Just wondering why our balance in FAGLB03 and GL Account Line Item Display is not tally.  What could be the reason and what should I do to have it reconciled?
    Thanks,
    Julie

    Hi,
    Please check the SAP note:
    Note 1223997 - Amounts incorrect in FAGLB03 navigation to FAGLL03 and FB03.
    1. There is a difference between FAGLB03 and navigating to FAGLL03.
    You display transaction figures of an account using FAGLB03.
    By double-clicking a line, you branch to the line items.
    The total of the items does not correspond to the balance.
    If you drill down to the 'Debit' or 'Credit' column, certain items may not be displayed, or too many items may be displayed. This occurs in particular with negative postings, for example because a negative posting 'reduces' the balances on the credit side.
    Therefore, this item should be displayed in the 'Debit' items when you navigate to FAGLL03. This does not work correctly.
    Reason and Prerequisites
    There is a program error or a data inconsistency
    If the problem symptoms are as above, kindly check in the system whether this note has been applied.
    Thanks
    Aravind

  • How to get the link between mara, ausp, cawn and cawnt tables

    hello ABAPERS
    i have got a requiremet in that i have to get the relation .
    how to get the link between mara, ausp, cawn and cawnt tables and also type how can we get link between  char value and char description in cawn and cawnt tables through ausp and mara tables.
    I would be very thankful  for ur help in advance.
    Thanks & Regards.
    soni

    Hi,
    Sample report using the linkage between tables;
    report batch_char no standard page heading
                              line-size  132
                              line-count 58(1)
                              message-id mm.
           Report by Batch Characteristic                                *
    Description          : Report by Batch Characteristic                *
    Declaration for Tables
    tables: mara,    " Material Master
            mard,    " Storage Location Data for Material
            t001w,   " Plants/Branches
            t001l,   " Storage Locations
            cabn,    " Characteristics
            inob.    " Link between Internal Number and Object
    Declaration for Constants
    constants : c_klart like ausp-klart value '023',     " Class Type
                c_obtab like inob-obtab value 'MCH1',    " Database Table
                c_flag  type c          value 'X',       " Flag
                c_c23   type i          value '23',      " Ratio
    Constants for Ratio Categories
                c_13    type p decimals 2 value '13.00', " For Ratio 13
                c_1499  type p decimals 2 value '14.99', " For Ratio 14.99
                c_15    type p decimals 2 value '15.00', " For Ratio 15
                c_1699  type p decimals 2 value '16.99', " For Ratio  16.99
                c_17    type p decimals 2 value '17.00', " For Ratio 17
                c_1899  type p decimals 2 value '18.99', " For Ratio 18.99
                c_19    type p decimals 2 value '19.00', " For Ratio 19
                c_2099  type p decimals 2 value '20.99', " For Ratio 20.99
                c_21    type p decimals 2 value '21.00', " For Ratio 21
                c_2299  type p decimals 2 value '22.99', " For Ratio 22.99
                c_23    type p decimals 2 value '23.00', " For Ratio 23
                c_g23(4) type c value '>=23',            " For Ratio >=23
                c_ratio(5) value 'RATIO',                  " For Ratio
    Constants for Storing Selected item field information
                c_cursor1(15) value 'I_OUTPUT1-MEINS',   " For Selected Base
                                                         " Unit of Measure
                c_cursor2(15) value 'I_OUTPUT1-MATNR',   " For Selected Base
                                                         " Material Number
                c_cursor3(15) value 'I_OUTPUT1-MAKTX',   " For Selected Base
                                                         " Material Des.
                c_cursor4(15) value 'I_OUTPUT1-CLABS',   "For Selected Base
                                                         " Stock Value
                c_cursor5(15) value 'I_OUTPUT1-ATFLV',   " For Selected Base
                                                        " Char.Value (Ratio)
                c_cursor6(5) value 'C_G23'.
    Declaration for Global Variables
    data : g_exit  type c,                            " Flag
           g_clabs1(16) type c,                       " Quantity
           g_clabs(18)  type c,                       " Quantity
           g_cursor(15) type c,                       " Cursor field name
           g_matnr     type mara-matnr,               " Material Number
           g_werks     type mchb-werks,               " Plant
           g_atinn(30) type c.                        " Character.
    Declaration for Internal tables
    Internal table to hold Batch Stock data
    data : begin of i_mchb occurs 0,
             matnr like mchb-matnr,      " Material Number
             werks like mchb-werks,      " Plant
             lgort like mchb-lgort,      " Storage Location
             charg like mchb-charg,      " Batch Number
             clabs like mchb-clabs,      " Stock Value
             meins like mara-meins,      " Unit of measure
             atflo like ausp-atflv,      " Char.Value (Ratio)
             atflv like ausp-atflv,      " Char.Value (Ratio)
           end of i_mchb.
    Internal table to hold Secondary List data
    data : begin of i_mchb1 occurs 0,
             werks like mchb-werks,      " Plant
             matnr like mchb-matnr,      " Material Number
             lgort like mchb-lgort,      " Storage Location
             charg like mchb-charg,      " Batch Number
             atinn like ausp-atinn,      " Char.Value
             clabs like mchb-clabs,      " Stock Value
             atflo like ausp-atflv,      " Char.Value (Ratio)
             atflv like ausp-atflv,      " Char.Value (Ratio)
           end of i_mchb1.
    Internal table to get the Plant Name
    data : begin of i_plant occurs 0,
             werks like t001w-werks,     " Plant
             name1 like t001w-name1,     " Name
           end of i_plant.
    Internal table to get the Material Description
    data : begin of i_makt occurs 0,
             matnr like makt-matnr,      " Material
             maktx like makt-maktx,     " Description
           end of i_makt.
    Internal table to hold AUSP data
    data : begin of i_ausp occurs 0,
             objek like ausp-objek,      " Object No
             atinn like cabn-atinn,      " Characteric value
             atflv like ausp-atflv,      " Characteristic Value
           end of i_ausp.
    Internal table to hold output data
    data : begin of i_output occurs 0,
             atinn like cabn-atinn,      " Characteric value
             werks like mchb-werks,      " Plant
             matnr like mchb-matnr,      " Material Number
             atnam like cabn-atnam,      " Characteristic
             atflv like ausp-atflv,      " Char.Value (Ratio)
             name1 like t001w-name1,     " Plant Description
             maktx like makt-maktx,      " Material Description
             clabs like mchb-clabs,      " Stock Value
             meins like mara-meins,      " Base Unit of Measure
           end of i_output.
    Internal table to hold final Output data
    data : begin of i_output1 occurs 0,
             atinn like cabn-atinn,      " Characteric value
             werks like mchb-werks,      " Plant
             matnr like mchb-matnr,      " Material Number
             atnam like cabn-atnam,      " Characteristic
             atflv(32) type c,           " Char.Value (Ratio)
             name1 like t001w-name1,     " Plant Description
             maktx like makt-maktx,      " Material Description
             clabs like mchb-clabs,      " Stock Value
             meins like mara-meins,      " Base Unit of Measure
           end of i_output1.
           Selection screen
    selection-screen begin of block b1 with frame title text-001.
    select-options: s_werks for t001w-werks obligatory,  " Plant
                    s_lgort for t001l-lgort,             " Stor.Location
                    s_matnr for mara-matnr  obligatory,  " Material No
                    s_atinn for cabn-atinn.              " Character.
    selection-screen end of block b1.
    At selection screen
    at selection-screen.
    Validation of Selection Screen Fields
      perform validate_screen.
    Start of selection
    start-of-selection.
    Get the Material and Batch Stock data from MARA and MCHB Tables
      perform get_mat_stock_data.
    Get the Material Group Text and Plant Name from T023T and T001W Tables
      perform get_plant_grp_data.
    Append the data into final Output Internal Table after getting the
    Characteristic Values data from INOB and AUSP Tables
      perform append_final_data.
    Processing if the Characteristics contain 'RATIO'
      perform collect_ratio.
    End-of-Page
    end-of-page.
      write /1(125) sy-uline.
    End of selection
    end-of-selection.
      if g_exit <> c_flag.
    Display the Report Output data
        perform display_report.
      endif.
    Top-of-Page
    top-of-page.
    Write the Report and Column Headings
      perform get_headings.
    at line-selection
    at line-selection.
      if sy-lsind = 1.
        perform display_batch.
      endif.
    Top of page during line-selection
    top-of-page during line-selection.
      perform heading_seclist.
          Form validate_screen
    Validation of Selection Screen fields
    form validate_screen.
    Validation of Plant
      clear t001w.
      if not s_werks[] is initial.
        select werks
          into t001w-werks
          from t001w
          up to 1 rows
          where werks in s_werks.
        endselect.
        if sy-subrc <> 0.
          message e899 with 'Enter Valid Plant'(002).
        endif.
      endif.
    Validation of Material Number
      clear mara.
      if not s_matnr[] is initial.
        select matnr
          into mara-matnr
          from mara
          up to 1 rows
          where matnr in s_matnr.
        endselect.
        if sy-subrc <> 0.
          message e899 with 'Enter Valid Material'(003).
        endif.
      endif.
    Validation of Storage Location
      clear t001l.
      if not s_lgort[] is initial.
        select lgort
          into t001l-lgort
          from t001l
          up to 1 rows
          where lgort in s_lgort.
        endselect.
        if sy-subrc <> 0.
          message e899 with 'Enter Valid Storage Location'(004).
        endif.
      endif.
    Validation of Characteristic Value
      clear cabn.
      if not s_atinn[] is initial.
        select atinn
          into cabn-atinn
          from cabn
          up to 1 rows
          where atinn in s_atinn.
        endselect.
        if sy-subrc <> 0.
          message e899 with 'Enter Valid Characteristic Value'(005).
        endif.
      endif.
    Validation of Plant, Material and Storage Location
      clear mard.
      select matnr werks lgort
        into (mard-matnr, mard-werks, mard-lgort)
        from mard
        up to 1 rows
        where matnr in s_matnr and
              werks in s_werks and
              lgort in s_lgort.
      endselect.
      if sy-subrc <> 0.
        message e899 with 'No Data found for the Selection Criteria'(006).
      endif.
    endform.                          "validate_screen
    *&      Form  get_headings
    Write the Report and Column Headings
    form get_headings.
      data: l_repid type sy-repid.
      l_repid =  sy-repid.
      call function 'Y_STANDARD_HEADING'
           exporting
                repid    = l_repid
                heading1 = sy-title.
      write:/1(125) sy-uline.
      format color col_heading on.
      write : /1  sy-vline,  2(18)   'Material Number'(008) centered,
              20  sy-vline,  21(40)  'Material Description'(011) centered,
              61  sy-vline,  62(22)  'Ratio'(009) centered,
              84  sy-vline,  85(18)  'Quantity'(010) centered,
             103  sy-vline, 104(20)  'Base Unit of Measure'(015) centered,
             125  sy-vline.
      write:/1(125) sy-uline.
      format color off.
    endform.                    "get_headings
    *&      Form  get_mat_stock_data
    Get the Material and Batch Stock data from MARA and MCHB Tables
    form get_mat_stock_data.
      clear: i_mchb,i_output, i_output1.
      refresh: i_mchb,i_output, i_output1.
      select a~matnr       " Material Number
             b~werks       " Plant
             b~lgort       " Storage Location
             b~charg       " Batch Number
             b~clabs       " Stock Value
             a~meins       " Base Unit of Measure
          into table i_mchb
          from mara as a inner join mchb as b
          on amatnr eq bmatnr
          where b~matnr in s_matnr and
                b~werks in s_werks and
                b~lgort in s_lgort.
      if sy-subrc <> 0.
        g_exit = c_flag.
        message s899 with 'No Data found for the Selection Criteria'(006).
        stop.
      endif.
      sort i_mchb by matnr werks lgort charg.
    endform.                    " get_mat_stock_data
    *&      Form  get_plant_grp_data
    Get the Material Group Text and Plant Name from T023T and T001W
    form get_plant_grp_data.
      if not i_mchb[] is initial.
    Get the Plant Description from t001w Table
        clear i_plant.
        refresh i_plant.
        select werks      " Plant
               name1      " Name
          into table i_plant
          from t001w
          for all entries in i_mchb
          where werks = i_mchb-werks.
    Get the Material Description from MAKT Table
        clear i_makt.
        refresh i_makt.
        select matnr      " Material number
               maktx      " Material Description
          into table i_makt
          from makt
          for all entries in i_mchb
          where matnr = i_mchb-matnr and
                spras = sy-langu.
        sort i_plant by werks.
        delete adjacent duplicates from i_plant comparing werks.
        sort i_makt by matnr.
        delete adjacent duplicates from i_makt comparing matnr.
      endif.
    endform.                   "form get_plant_grp_data.
    *&      Form  append_final_data
    Append the data into final Internal Table
    form append_final_data.
      data : l_matbatch(28),
             l_tabix like sy-tabix.
      if not i_mchb[] is initial.
        loop at i_mchb.
          l_tabix = sy-tabix.
          clear l_matbatch.
          concatenate i_mchb-matnr i_mchb-charg into l_matbatch.
          move-corresponding i_mchb to i_output.
    Get the Plant Description from i_plant Table
            read table i_plant with key werks = i_mchb-werks binary search.
            if sy-subrc = 0.
              i_output-name1 = i_plant-name1.
            endif.
    Get the Material Description from i_makt Table
          read table i_makt with key matnr = i_mchb-matnr binary search.
          if sy-subrc = 0.
            i_output-maktx = i_makt-maktx.
          endif.
    Get the Characteristic Values data from INOB and AUSP Tables
          clear inob.
          select single cuobj from inob
              into inob-cuobj
              where klart = c_klart and
                    obtab = c_obtab and
                    objek = l_matbatch.
          if sy-subrc = 0.
            select objek
                   atinn
                   atflv
               from ausp
               into table i_ausp
               where objek = inob-cuobj and
                     atinn in s_atinn   and
                     klart = c_klart.
            sort i_ausp by objek atinn.
            loop at i_ausp.
              clear cabn.
              select single atinn atnam from cabn
                         into (cabn-atinn,cabn-atnam)
                         where atinn = i_ausp-atinn.
              if sy-subrc = 0.
    If the ratio value is between 13-14.99, display 13
                if cabn-atnam cs c_ratio.
                  if i_ausp-atflv between c_13 and c_1499.
                    i_mchb-atflo = i_ausp-atflv.
                    i_mchb-atflv = c_13.
    If the ratio value is between 15-16.99, display 15
                  elseif i_ausp-atflv between c_15 and c_1699.
                    i_mchb-atflo = i_ausp-atflv.
                    i_mchb-atflv = c_15.
    If the ratio value is between 17-18.99, display 17
                  elseif i_ausp-atflv between c_17 and c_1899.
                    i_mchb-atflo = i_ausp-atflv.
                    i_mchb-atflv = c_17.
    If the ratio value is between 19-20.99, display 19
                  elseif i_ausp-atflv between c_19 and c_2099.
                    i_mchb-atflo = i_ausp-atflv.
                    i_mchb-atflv = c_19.
    If the ratio value is between 21-22.99, display 21
                  elseif i_ausp-atflv between c_21 and c_2299.
                    i_mchb-atflo = i_ausp-atflv.
                    i_mchb-atflv = c_21.
    If the ratio value is greater than or equal to 23, display 23
                  elseif i_ausp-atflv >= c_23.
                    i_mchb-atflo = i_ausp-atflv.
                    i_mchb-atflv = c_23.
                  endif.           " Condition for RATIO values
                else.              " If characteristic does contain RATIO
                  i_mchb-atflv = i_ausp-atflv.
                endif.
                i_output-atinn = cabn-atinn.
                i_output-atnam = cabn-atnam.
                i_output-atflv = i_ausp-atflv.
                i_mchb1-matnr = i_mchb-matnr.
                i_mchb1-werks = i_mchb-werks.
                i_mchb1-lgort = i_mchb-lgort.
                i_mchb1-charg = i_mchb-charg.
                i_mchb1-clabs = i_mchb-clabs.
                i_mchb1-atinn = i_ausp-atinn.
                i_mchb1-atflo = i_mchb-atflv.
                i_mchb1-atflv = i_ausp-atflv.
                append : i_output, i_mchb1.
                clear i_mchb1.
                modify i_mchb index l_tabix transporting atflo atflv .
              endif.
            endloop.
          endif.
        endloop.
      endif.
    Checking whether the table is filled or not
      if not i_output[] is initial.
        sort i_output by atinn werks matnr atflv.
      else.
        g_exit = c_flag.
        message s899 with 'No Data found for the Selection Criteria'(006).
      endif.
    Delete the records where RATIO is less than 13.
      delete i_output where atnam cs c_ratio and atflv lt c_13.
    endform.                    "append_final_data
    *&      Form  display_report
    Display the Report Output data
    form display_report.
    data: l_tabix like sy-tabix.
      loop at i_output1.
        l_tabix = sy-tabix.
    At new Characteristic
         at new atinn.
          read table i_output1 index l_tabix.
          format color 1 intensified on.
          write: /1 sy-vline, 2(20) 'Characteristic Name:'(007),
                 23(40) i_output1-atnam,
                 125 sy-vline.
          format color off.
          format color 4 intensified on.
          write: /1 sy-vline, 2(20) 'Plant Name         :'(022),
                 23(4) i_output1-werks, 29(30) i_output1-name1,
                 125 sy-vline.
          format color off.
          write /1(125) sy-uline.
        endat.
        clear: g_clabs, g_clabs1.
        format color col_normal.
        write :/1 sy-vline,  2(18)   i_output1-matnr,
               20 sy-vline,  21(40)  i_output1-maktx,
               61 sy-vline.
        if i_output1-atflv = c_c23.
          write: 62(22)  c_g23 centered.
        else.
          shift i_output1-atflv left deleting leading space.
          write: 62(22)  i_output1-atflv centered.
        endif.
        write:  84     sy-vline,
               103     sy-vline,
               110(5)  i_output1-meins.
    If the quantity value is negative
        if i_output1-clabs ge 0.
          write: 85(18) i_output1-clabs unit i_mchb-meins,
                125     sy-vline.
        else.
          i_output1-clabs = - i_output1-clabs.
          write i_output1-clabs unit i_mchb-meins to g_clabs1.
          condense g_clabs1.
          concatenate '(' g_clabs1 ')' into g_clabs separated by space.
          write: 85(18) g_clabs right-justified,
               125 sy-vline.
        endif.
        format color off.
        hide : i_output1.
        new-line.
    At end of material
        at end of matnr.
          sum.
          move : i_output1-matnr to g_matnr.
          format color 3 intensified on.
          write /1(125) sy-uline.
          write :/1 sy-vline,  2(25) 'Total for Material      :'(012),
                 28(18) g_matnr.
          if i_output1-clabs ge 0.
            write: 85(18) i_output1-clabs  unit i_mchb-meins,
            125 sy-vline.
          else.
            i_output1-clabs = - i_output1-clabs.
            write i_output1-clabs unit i_mchb-meins to g_clabs1.
            condense g_clabs1.
            concatenate '(' g_clabs1 ')' into g_clabs separated by space.
            write: 85(18) g_clabs right-justified,
                 125 sy-vline.
          endif.
          write: 125 sy-vline.
          format color off.
          write /1(125) sy-uline.
        endat.
    At end of plant
        at end of werks.
          sum.
          move : i_output1-werks to g_werks.
          format color 3 intensified off.
          write :/1 sy-vline,  2(25) 'Total for Plant          :'(013),
                 28(4) g_werks.
          if i_output1-clabs ge 0.
            write:  85(18) i_output1-clabs  unit i_mchb-meins,
            125 sy-vline.
          else.
            i_output1-clabs = - i_output1-clabs.
            write i_output1-clabs unit i_mchb-meins to g_clabs1.
            condense g_clabs1.
            concatenate '(' g_clabs1 ')' into g_clabs separated by space.
            write: 85(18) g_clabs right-justified,
                 125 sy-vline.
          endif.
          format color off.
          write /1(125) sy-uline.
        endat.
    At end of  characteristic
        at end of atinn.
          read table i_output1 index l_tabix.
          sum.
          format color 3 intensified on.
          write :/1 sy-vline,  2(25) 'Total for Characteristic:'(014),
                 28(25) i_output1-atnam.
          if i_output1-clabs ge 0.
            write:  85(18) i_output1-clabs  unit i_mchb-meins,
            125 sy-vline.
          else.
            i_output1-clabs = - i_output1-clabs.
            write i_output1-clabs unit i_mchb-meins to g_clabs1.
            condense g_clabs1.
            concatenate '(' g_clabs1 ')' into g_clabs separated by space.
            write: 85(18) g_clabs right-justified,
                 125 sy-vline.
          endif.
          format color off.
          write /1(125) sy-uline.
        endat.
      endloop.
    endform.                    " display_report
    *&      Form  DISPLAY_BATCH
         Display the batch details for the seclected material            *
    form display_batch.
    Get the batch details for the selected material
      get cursor field g_cursor.
      if g_cursor = c_cursor1 or
         g_cursor = c_cursor2 or
         g_cursor = c_cursor3 or
         g_cursor = c_cursor4 or
         g_cursor = c_cursor5 or
         g_cursor = c_cursor6.
        format color 3.
        write: /1 sy-vline,
                2(17) 'Material Number :'(020),
               20(17) i_output1-matnr,
               94 sy-vline.
        format color off.
        write /1(94) sy-uline.
        loop at i_mchb1 where matnr = i_output1-matnr and
                              atinn = i_output1-atinn and
                              atflo = i_output1-atflv.
          format color col_normal.
          shift i_mchb1-charg left deleting leading '0'.
          write :/1 sy-vline,  2(16) i_mchb1-lgort centered,
                 18 sy-vline, 19(17) i_mchb1-charg centered,
                 36 sy-vline.
          if i_output1-atnam cs c_ratio.
            write: 37(29) i_mchb1-atflv
                           exponent 0 decimals 2 centered.
          else.
            write : 37(29) i_mchb1-atflv
                          exponent 0 decimals 0 centered.
          endif.
          write : 66 sy-vline, 67(27) i_mchb1-clabs unit i_mchb-meins,
                  94 sy-vline.
          format color off.
        endloop.
        write /1(94) sy-uline.
      else.
        message s899 with 'Invalid cursor position'(016).
        exit.
      endif.
    endform.                    " DISPLAY_BATCH
    *&      Form  HEADING_SECLIST
          Write the Column Headings for Interactive Report
    form heading_seclist.
      write /1(94) sy-uline.
      format color col_heading on.
      write :/1 sy-vline,  2(16) 'Storage Location'(021),
             18 sy-vline, 19(17) 'Batch Number'(017) centered,
             36 sy-vline, 37(29) 'Characteristic Value'(018) centered,
             66 sy-vline, 67(27) 'Quantity'(019) centered,
             94 sy-vline.
      write /1(94) sy-uline.
      format color off.
    endform.                    " HEADING_SECLIST
    *&      Form  COLLECT_RATIO
          Display the Characteristic ratio data
    form collect_ratio.
      loop at i_output.
        clear g_atinn.
        i_output1-atinn = i_output-atinn.
        i_output1-atnam = i_output-atnam .
        i_output1-werks = i_output-werks.
        i_output1-name1 = i_output-name1.
        i_output1-matnr = i_output-matnr.
        i_output1-maktx = i_output-maktx.
        i_output1-clabs = i_output-clabs.
        i_output1-meins = i_output-meins.
        call function 'CONVERSION_EXIT_ATINN_OUTPUT'
             exporting
                  input  = i_output-atinn
             importing
                  output = g_atinn.
        if g_atinn cs c_ratio.
    If the ratio value is between 13-14.99, display 13
          if i_output-atflv between c_13 and c_1499.
            i_output1-atflv = c_13.
    If the ratio value is between 15-16.99, display 15
          elseif i_output-atflv between c_15 and c_1699.
            i_output1-atflv = c_15.
    If the ratio value is between 17-18.99, display 17
          elseif i_output-atflv between c_17 and c_1899.
            i_output1-atflv = c_17.
    If the ratio value is between 19-20.99, display 19
          elseif i_output-atflv between c_19 and c_2099.
            i_output1-atflv = c_19.
    If the ratio value is between 21-22.99, display 21
          elseif i_output-atflv between c_21 and c_2299.
            i_output1-atflv = c_21.
    If the ratio value is greater than or equal to 23, display 23
          elseif i_output-atflv >= c_23.
            i_output1-atflv = c_23.
          endif.
          write i_output1-atflv to i_output1-atflv .
        else.
          write i_output-atflv to i_output1-atflv exponent 0 decimals 0.
        endif.
        collect i_output1.
        clear   i_output1.
      endloop.
      sort i_output1 by atinn werks matnr atflv.
    endform.                    " COLLECT_RATIO
    Reward if useful..
    Regards,
    Anji

  • How do i remove the link between my apple ID and my mobile number?

    i decided to move away from iPhone a couple of days ago as a result of renewing my contract. When I got my new phone, I factory re-set it and handed it in to my network provider as part of a recycling scheme. Since getting my new phone, when people send me texts they are still sending as iMessages. I have logged onto my iTunes and removed my iPhone from the account but still nothing. How do I completely remove the link between my mobile nuber and iMessenger?

    Contact Apple support to deactivated iMessage: https://www.apple.com/support/appleid/contact/

  • Link between Basic Salary Wagetype and Bank Transfer Wagetype?

    Hi Experts
    In my SAP System BASIC, HRA,C.A and E A wage types are assigned only for Expensive A/c's not for Balance sheet account but when am simulating the total figure was going to bank transfer balance sheet account.it is correct.but Where we can find the the link between HRA Wage type and Bank Transfer wage type Account?
    thanks
    venu

    All the wagetypes Basic,hra etc are expenses to the company and salary payable is liability to the company ......So your Bank Transfer WT total consists of all the Wts ....so Basic,hra etc WTs goes to the Expenses a/c and Bank Transfer goes to the Balance sheet a/c . Balance sheet tallied with all expences equal to liabilities .
    Mohan

  • Link between Credit Risk Category and Terms of Payment

    Hi,
    Is there a link between the Credit risk category and the terms of payment. Where can we maintain this.
    For instance, if risk category is x, the top is a, risk category is y, top is b.
    Please suggest.

    There is no link between credit risk category and Terms of Payment. The Risk Category is assigned to credit limit of the customer which determines if it will be blocked at certain level for sales transactions or just a warning message that the customer is over the limit. For the terms of payment, it just determines when it's due or whether it's overdue or not.

Maybe you are looking for

  • Best Two in Three Numbers

    Hi i had written a logic for finding out two best nos out of three. But i think i m using BAD logic, any good guess than this?? int a, b, c, max1, max2; a = 10; b = 20; c = 30; max1 = a > b ? (a > c ? a : b) : (b > c ? b : c); if(max1 == a )    max2

  • How can i rid out the pops up in safari?

    when ever i open the safari page all ad pops up and distract me. and these is new to me.

  • Premiere Elements 9 Videos in Full HD Qualität exportieren

    Wie kann ich mit Premiere Elements 9 Videos in Full HD Qualität exportieren

  • Service entry deletion

    Hi MM Experts 1) I have create 1 service entry then delete it but only few services deleted and remaining still not deleted. while creating service entry system showing error already created. pls tell me how can i delete remaining services from servi

  • Unknown type TABLE for element Error

    This question i am posting on behalf of one of my friend In RF transaction, created a screen that contains table control. The table control has created using wizard If we run the transaction with in SAPGui its working fine. After creating Internet se