Linking between Sales order data and Biling condition

Hi Bwers,
Currently we are geneating a report with Sales order Item level (2lis_11_VAITM) information and Biling conditions(2lis_13_VDKON). We have respective DSO for both datasources (Sales order DSO and Biling Condition DSO). We have to pull both information into a report.
We have sales order number (0DOC_NUM) in Sales DSO and Biling document number (0BILL_NUMber) in Biling DSO. And we found Sales order Number (0BILL_NUM_0DOC_NUMB) as an navigational attribute for Biling DSO.
We are trying to extract Billing condition type and Billing condition value from Billing DSO.
Now the question's are:
1. Can I use Sales order number as linking field for Both DSO' or not. Though It is an Navigational attribute for Biling document number in Biling DSO.
2. Is the Sales order number and Billing Document number both are same or not. What is the linking field between sales order info to Biling info.
2. How to bring Sales order info and Biling info into a report through Infoset. If infoset which link should I use bring both info into a report.
3. Or Multiprovider is the right one.
3. Please let me know if any other linking fields are existed between these two datasources other than Sales order.
All the helpful answers are awareded with full points.
Regards,
Venkat

1. Can I use Sales order number as linking field for Both DSO' or not. Though It is an Navigational attribute for Biling document number in Biling DSO.
- yes you can link, Navigation attrbute does not matter
2. Is the Sales order number and Billing Document number both are same or not. What is the linking field between sales order info to Biling info.
--one sales order number may correspond to different billing number including the one which shares the same number.
2. How to bring Sales order info and Biling info into a report through Infoset. If infoset which link should I use bring both info into a report.
-- Multiprovider is the best option while dealing with such cases.
3. Or Multiprovider is the right one.
--yes.
3. Please let me know if any other linking fields are existed between these two datasources other than Sales order.
there may be possibilty of other fields also like Profit center, Controling area etc depending upon your project requirment

Similar Messages

  • Link Between Sales Order Type and Customer/Material Exclusion

    Hi,
    Any one know the  Link Between Sales Order Type  and Customer/Material exclusion tables (Transaction: VB03 ) ?

    Hello,
    For Tcode VB03 you can check KOTG001 for Customer/Material.
    Thanks &Regards,
    Abhijit

  • Regarding creating a LOOSE LINK between Sales Order and Vehicle

    Hi,
    Does anyone has any idea on how to establish a LOOSE LINK between Sales Order and Vehicle using BAPI_VEHICLE_CREATE or any other Function module.
    Any help will be highly appreciated and rewarded.
    Kind Regards,
    Tanuja

    Dear Kumar,
    Strategy - 40
    Consumption of PIR (not Redution)
    1) the first point in strategy in 40 is, incoming sales order consumes PIR
    2 )both sales order and PIR takes place in MRP planning run
    2) this is where it is in mostly used in many indutries
    just a small example how this strategy works
    1) creat PIR for ur FERT- 100Nos
    2) check in MD04- u will get PIR (VSF) as 100
    3) now creat sales order for 120 for same month
    4 )run MRP for that particular FERT
    5) check the result in MD04, here ur PIR gets vanishied and an plan order will be generated for 120 Nos.
    Regards
    kumar
    Edited by: kumar kumar on Jul 22, 2009 8:29 AM

  • Link between Sales order and Credit master sheet

    Hi,
    Plz explain the link between sales order and credit master sheet.
    Thanks and regards
    CSR

    Hi,
    Credit master is related to Customer.
    Credit limit will be assigned to a customer by using the T.Code FD32.
    Credit control area will be assigned to a customer.
    You can the credit control area for a customer in the table "KNVV".
    Goto the T.Code "FD32".Enter your customer number and credit control area.Select the status tab.
    Here you can maintain the credit limit.If you leave blank means the limit is 0.00.
    Next thing is goto the T.Code "OVAK".
    Select your sales order.Maintain the "Credit limit check" for your order type.
    Goto the T.Code "OVA8".Select your valid combination.Here,you can activate either the static or dynamic credit limit checks.
    If you create the sales order by using the customer,initially the system will check for the credit limit.If it is 0.00 and credit check functionality is activatd in the above specified T.Codes,then creditcheck will happen and order will be blocked for releasing of credit by using the T.Code "VKM3".Authorised persons have to release this credit block.Suppose,you have maintained this credit limit as "1000Rs/-" and you are creating the order of value "550Rs/-",then your order will not be blocked even though the credit check functionality is activated for your order type.
    In this way,sales order is in turn related to credit master.
    Regards,
    Krishna.

  • Linking Between Sales Order And Purchase ORder

    Dear Gurus,
      How to link the Sales Order Number and Purchase Order Number. I know the Sales Order Number and I need the tables from which I can know the Purchase Order Numbers for that Sales Order Number.
    Points will be awarded.
    Thanks,
    Ravi

    Hi,
    Goto Table Mseg-kdauf is sales order no.
    get mseg-ebeln is purchase order.
    Or u can do the following code.
    from sales order no VBELN get VBFA-VBELV.
    SELECT SINGLE vbeln  FROM  likp
             INTO l_delno
             WHERE  vbeln   = vbfa-vbelv.
    SELECT SINGLE ebeln
               INTO l_sono
               FROM ekbe
               WHERE  belnr = l_delno    
               AND   bewtp = 'L' .  
    L_DELNO IS PURCHASE ORDER.
    If it is helpfull pls reward it.
    Regards
    Srimanta

  • Link between sales order to Credit management

    Where can we link between sales order to Credit management?

    HI Gopala rao.,
                       In VOV8 sales document type there is <b>credit limit & Credit group</b> Where we asign the credit mage,ment data to Order
    The configuration part of credit managemnt is
    CREDIT MANAGEMENT:
    A credit limit may be a customer’s credit limit, which is the permitted limit of value of open items, such as invoices not yet paid, plus the value of open sales orders.
    The credit limit is the total combined value of the following documents:
    Net value of sales order
    Open Sales order: order created, but not delivered
    Open deliveries: delivered, but not invoiced
    Open billing doc: value of billing doc, which has not yet been forwarded to accounting
    Open items: forwarded to accounting, but not settled.
    Types of Credit Check
    • Simple Credit Check
    • Automatic Credit Check
    o Static
    o Dynamic
    Simple Credit Check:
    SPRO- IMG- SD- Basic Functions- Credit Mgmt/ Risk Mgmt- Simple Credit Check- Assign Credit Check to Doc Types.
    • Based on sales doc types
    • It will check all the above-mentioned docs & if the credit limit exceeds, the system responds in the way defined by you in the configuration menu.
    • Cannot differentiate according to customer
    3 ways to Control the Simple Credit Check:
    A: warning
    B: error message: the doc cannot be saved
    C: warning message with delivery block: the doc can be saved but is automatically blocked for delivery.
    Automatic Credit Check:
    This credit mgmt control is maintained by using the automatic credit control functionality. The automatic credit control divides the sales doc types, the delivery doc types, & goods issue into specific credit groups. It also uses the customer’s risk category as assigned to the CMD of the payer & assigns an outcome proc to the combination of the above 2 objects, i.e. the credit group & customer risk category along with the credit control area. The definition of customer’s risk category is carried out in the fin accounting module.
    A customer’s risk category is a grouping category that controls the credit check when automatic credit control takes place. Thus one can assign high-risk customers to risk category for e.g. A01, medium risk to B01 and low risk to C01.
    Automatic credit check divides customers in to 3 categories:
    • High-risk customers,
    • Low risk customers &
    • Medium risk customers.
    A credit check &#61614;can only occur at 3 places: Credit Group
    Sales order: for high risk customers
    Delivery: for medium risk customers
    Goods Issue: for low risk customers
    Credit Control Area (CCA): highest organizational element in credit management. A credit control area is an organizational unit that is comprised of one or more company codes. A company code can have no more than one credit control area. Defined by FI.
    Menu Path to create Credit Control Area: OB45: FI people.
    SPRO- IMG- Enterprise Stru- Definition- Fin Accounting- Define Credit Control Area
    Credit Control Area Description
    0001 Credit control area 0001
    1000 Credit control area Europe
    Menu Path to Assign Company Code to Credit Control Area: OB38: FI people.
    SPRO- IMG- Ent Stru- Assignment- Fin Accounting- Assign Comp Code to CCA
    • It is possible to assign Credit Control Area to a Sales Area. This is more specific assignment than the assignment to Company Code.
    Company code Company name City Credit Control Area Over write CCA
    Menu Path for Defining Risk Categories: OB01: FI people
    SPRO- IMG- Fin Accounting- Account Receivables & Payables- Credit Mgmt- Credit Control Account- Define Risk Categories.
    Risk Category CCA Name
    001 4500 Low risk
    002 4500 Medium risk
    003 4500 High risk
    Menu Path for defining Credit Groups: OVA6
    SPRO- IMG- SD- Basic Function- Credit Mgmt/ Risk Mgmt- Credit Mgmt:
    • Define Credit Groups: OVA6
    • Assign Credit Groups to Sales Doc’s & Delivery Doc’s
    o Credit Limit check for Order Types: OVAK
    o Credit Limit check for Delivery Types: OVAD
    • Define Automatic Credit Control: OVA8
    Define Credit Croups: OVA6
    One merely creates a credit group for each differentiation in the doc type. You enter the credit groups when you configure the sales doc types for credit management & define the automatic credit check. The following credit groups are contained in the standard R/3 system:
    • 01: credit group for sales order
    • 02: credit group for delivery
    • 03: credit group for goods issue
    CG (Credit Group) Doc Credit Group
    01 Credit group for sales order
    02 Credit group for delivery
    03 Credit group for goods issue
    Assign Sales Documents & Delivery Documents:
    Sales Doc Type Descp Check Credit Credit Group
    OR Std Order D 01
    Delivery Type Descp Del Credit Group GI Credit Group
    LF Delivery 02 03
    Define for each sales doc type whether a credit check should be carried out. Enter ‘D’ if an automatic credit check should be carried out.
    Specify a Credit Group
    Specify a Credit Group for the Delivery Type for which you want to carry out a credit check
    Specify a Goods Issue Credit Group for the Delivery Type for which a credit check is to be carried out for goods issue.
    SIMPLE CREDIT CHECK CANNOT BE ASSIGNED TO DOCUMENTS.
    Define Automatic Credit Control:
    One can now assign settings to the combination of the Credit Control Area, the Customer Risk Category & the Credit Group.
    CCA Risk Cat Credit Group Credit Control
    4500 001 01 Low risk sales orders
    4500 001 02 Low risk deliveries
    4500 001 03 Low risk goods issue
    4500 002 01 Medium risk sales orders
    4500 002 02 Medium risk deliveries
    4500 002 03 Medium risk goods issue
    4500 003 01 High risk sales orders
    4500 003 02 High risk deliveries
    4500 003 03 High risk goods issue
    Select line item and go to details, you can decide whether to do Static or Dynamic Credit Check. Credit Horizon can also assigned here. Additional function checks can be performed here:
    • A credit check when the maximum document value is exceeded.
    • A credit check when changing critical fields.
    The risk category assignment occurs in the same place as the customer’s credit limit, which is the customers credit management screen. That is, the risk category is assigned to the customer by the Finance in transaction code FD32.
    The customer credit master record is divided in to 5 views:
    • Overview Screen: gives an overview of credit settings in relation to the customer, including his credit limit, credit exposure, the %tage of credit limit used, his payment data & his risk category.
    • Address: view gives the customers address details as they appear in CMD
    • Central Data: is a view that shows the total credit limit the customer can receive across all credit control areas as well as the maximum limit he can receive in one credit control area.
    • Status: view shows the customer’s actual individual details according to particular CCA being investigated. This includes his credit limit, percentage used, credit exposure, risk category, whether he is blocked due to credit or not.
    • Payment history: view displays the payments made by the customer for a particular credit control area where a comp code is assigned.
    Static Credit Check Dynamic Credit Check
    Net Doc Value Net Doc Value
    Open Order Open Order
    Open Delivery Open Delivery
    Open Billing Open Billing
    Open Item Open Item
    Compares the total combined values of the above-mentioned documents to credit limit. Plus credit horizon. Compares the values of the following documents to credit limit + credit horizon.
    Credit horizon has an attached time period that states that the system is not to include sales orders in the total of outstanding items created after that specified period i.e. for the purpose of evaluating credit, you want the system to ignore all open orders that are due for delivery after the horizon date. Maintained for low & medium risk customers.
    Update Groups
    Basically it is a info structure where system stores all the data about credit limit. The credit relevant data is updated in a info structure, where it is accessed & updated. Thus each automatic credit control must be assigned an update group.
    • Update Group 000012
    • Update Group 000015: delivery & billing
    • Update Group 000018: sales order, delivery & billing.
    Update group 000012, updates at:
    • Sales doc: increased order value
    • Delivery: decreased order value & increased delivery value
    • Billing: decreased delivery value & increased billing amount
    • Invoice: decreased billing amount & increased open item value.
    Release Blocked Sales Order/ Deliveries:
    • VKM3: sales order
    • VKM5: delivery
    • VKM4: both
    One can see the offending document. Note on the right hand side, the ‘Status Field’. This shows the check, the doc failed. If this field is empty, the doc did not fail a credit check, even though it may be in the list of SD documents that are “required to be released”.
    To release the doc, one indicates the doc to be released and then clicks on the ‘Release Button’. The result is the offending doc entry, highlighted green. One then proceeds to save, after which you are informed the doc number has been released.
    • Net value with sub total ‘A’, in pricing proc, will be the basis for credit limit.
    REWARD if helpfull
    Thanks & Regards
    Narayana
    Message was edited by:
            manam narayana

  • Urgent!!!Need code to fetch all sales order data and download to flat file

    urgent!!!Need code to fetch all sales order data and download to flat file

                  D A T A B A S E  T A B L E S                          *
    TABLES: vbak,                          "Sales Document: Header Data
            VBAP,                          "Sales Document: Item Data
            MARA,VAPMA,VBPA,VBLB,VBEP,
             VBKD.   "Murali Poli                         .
                  I N T E R N A L   T A B L E S                         *
    Internal table to hold the Delphi material numbers file
    DATA: BEGIN OF tbl_matnr OCCURS 0,
            matnr LIKE mara-matnr,         "Material number
          END   OF tbl_matnr.
    Internal table to hold customer cross ref data
    DATA: BEGIN OF TBL_CUST_SA OCCURS 0,
            OLD_KUNNR LIKE KNA1-KUNNR,     "Old Customer
            OLD_VKORG LIKE A004-VKORG,     "Old Sales organisation
            OLD_VTWEG LIKE A004-VTWEG,     "Old Distribution channel
            NEW_KUNNR LIKE KNA1-KUNNR,     "New Customer
            NEW_VKORG LIKE A004-VKORG,     "New Sales organisation
            NEW_VTWEG LIKE A004-VTWEG,     "New Distribution channel
            PARVW LIKE VBPA-PARVW ,         "Partner function
    END   OF TBL_CUST_SA.
    Internal table to check the material numbers of the input file
    DATA: tbl_mara LIKE tbl_matnr OCCURS 0 WITH HEADER LINE.
    Work area to hold the header record
    DATA: BEGIN OF w_sa_header,
             recordtype(1),                "Record type
             schedulingagreement(4),       "SA Type
             contractreference(10),        "Contract Reference
             salesorg(4),                  "Sales Organization
             distrchannel(2),              "Distribution channel
             division(2),                  "Sales division
             PONUMBER(35),                 "Purchase order number"gsbhondave
             soldtoparty(12),              "Sold-to party
             shiptoparty(12),              "Ship-to party
             collectivenumber(10),         "Collective number
             description(40),              "Description
             roundqty(13),                 "Rounding Qty
             pdsi(4),                                           "PDI
             correctiondeliverydate(8),    "Correction Delivery Dt
             correctionqty(13),            "Correction Qty
             cumulativereceivedqty(13),    "Cumulative Received Qty
             forecastdeliveryschedule(17), "Forecast Delivery Schedule
             forecastdelscheddate(8),      "Forecast Delivery Schedule Dt
             jitdeliveryschedule(17),      "JIT Delivery Schedule
             jitdeliveryscheduledate(8),   "JIT Delivery Schedule Dt
             materialnumber(18),           "Material number
             plant(4),                     "Plant
             item_category(4),             "Item Category
             suppliercode(15),             "Supplier code
             scac(4),                      "SCAC
             deloc(12),                    "DELOC
             pkg_id(12),                   "Packaging ID
             catno(30),                    "Ultimate Cust Part
             lgort(4),                     "Storage Location
             vstel(4),                     "Shipping point
    Adding fields by Murali Poli
             VSBED(2),                     "Shipping conditions
             INCO1(3),                     "Incoterms (part 1)
             INCO2(28),                    "Incoterms (part 2)
             ZECN(1),                      "Engineering Change Letter
    End of Adding fields by Murali Poli
           END OF w_sa_header.
    Work area to hold the forecast record
    DATA: BEGIN OF w_sa_forecast,
             recordtype(1),                "Record Type
             dateformat(1),                "Date format
             forecastdate(8),              "Forecast date
             forecastorderqty(13),         "Order Qty
           END OF w_sa_forecast.
    Work area to hold the jit record
    DATA: BEGIN OF w_sa_jit,
             recordtype(1),                "Record Type
             dateformat(1),                "Date format
             jitdate(8),                   "JIT date
             jittime(6),                   "JIT Time
             jitorderqty(13),              "Order Qty
           END OF w_sa_jit.
    Internal table to hold the Extracted data
    DATA: BEGIN OF tbl_record OCCURS 0,
            record_type,
            DATA(400), " changed from 325 to 400
           END OF tbl_record.
    Internal table to capture the errors
    DATA: BEGIN OF tbl_error OCCURS 0,
            error_text(135),
          END   OF tbl_error.
    Internal table to hold the records of VBAP_VAPMA
    DATA: BEGIN OF tbl_vbap_vapma OCCURS 0,
    VBELN LIKE VAPMA-VBELN, "Sales and distribution document number
    POSNR LIKE VAPMA-POSNR,                "Item number
    AUART LIKE VAPMA-AUART,                "SA Type
    VKORG LIKE VAPMA-VKORG,                "Sales Organization
    VTWEG LIKE VAPMA-VTWEG,                "Distribution channel
    SPART LIKE VAPMA-SPART,                "Division
    KUNNR LIKE VAPMA-KUNNR,                "Sold-to
           plavo like vbap-plavo, "PDI
    MATNR LIKE VAPMA-MATNR,                "Material number
    WERKS LIKE VAPMA-WERKS,                "Plant
    TRVOG LIKE VAPMA-TRVOG,                "Transaction group
    VBTYP LIKE VBAK-VBTYP, "SD document category "Murali Poli
    VSBED LIKE VBAK-VSBED, "Shipping conditions   "Murali Poli
    BSTNK LIKE VBAK-BSTNK,  " Purchase order number " gsbhondave
    KTEXT LIKE VBAK-KTEXT,
    VGBEL LIKE VBAP-VGBEL,                 "Reference document no
    ABLFZ LIKE VBAP-ABLFZ,                 "Rounding qty
    PSTYV LIKE VBAP-PSTYV,                 "Item category
    LGORT LIKE VBAP-LGORT,                 "Storage location
    VSTEL LIKE VBAP-VSTEL,                 "Shipping point
    END   OF TBL_VBAP_VAPMA.
    DATA: BEGIN OF TBL_VBAP OCCURS 0,
    VBELN LIKE VAPMA-VBELN,
    POSNR LIKE VAPMA-POSNR,
    VGBEL LIKE VBAP-VGBEL,
    ABLFZ LIKE VBAP-ABLFZ,
    PSTYV LIKE VBAP-PSTYV,
    LGORT LIKE VBAP-LGORT,
    VSTEL LIKE VBAP-VSTEL,
    END   OF TBL_VBAP.
    Adding by Murali Poli
    DATA:BEGIN OF TBL_VBKD OCCURS 0,
          VBELN LIKE  VBKD-VBELN,
          POSNR LIKE  VBKD-POSNR,
          INCO1 LIKE  VBKD-INCO1,
          INCO2 LIKE  VBKD-INCO2,
         END OF TBL_VBKD.
    End by Murali Poli
    Internal table to hold temporarily the records of VBAP_VAPMA
    DATA: tbl_vbap_vapma_temp LIKE tbl_vbap_vapma OCCURS 0 WITH HEADER LINE.
    Internal table to hold the records of VBPA
    DATA: BEGIN OF tbl_vbpa OCCURS 0,
            vbeln LIKE vbpa-vbeln,         "Sales and distribution
                                           "document number
            posnr LIKE vbpa-posnr,         "Item number
            parvw LIKE vbpa-parvw,         "SP Partner type
            kunnr LIKE vbpa-kunnr,         "Customer number
            lifnr LIKE vbpa-lifnr,         "SCAC code     "DN3K923909
          END   OF tbl_vbpa.
    Internal table to hold the records of VBLB (Forecast)
    DATA: BEGIN OF tbl_vblb_forecast OCCURS 0,
            vbeln  LIKE vblb-vbeln,
            posnr  LIKE vblb-posnr,
            abart  LIKE vblb-abart,        "Release type
            abefz  LIKE vblb-abefz,        "Cumulative Quantity
                                           "Received by Customer
            labnk  LIKE vblb-labnk,        "Delivery schedule
            abrdt  LIKE vblb-abrdt,        "Deivery date
            gjkun LIKE vblb-gjkun,         "Current fiscal year
            vjkun LIKE vblb-vjkun,         "Previous fiscal year
          END   OF tbl_vblb_forecast.
    Internal table to hold the records of VBLB (JIT)
    DATA: BEGIN OF tbl_vblb_jit OCCURS 0,
            vbeln  LIKE vblb-vbeln,
            posnr  LIKE vblb-posnr,
            abart  LIKE vblb-abart,        "Release type
            abefz  LIKE vblb-abefz,        "Cumulative Quantity
                                           "Received by Customer
            labnk  LIKE vblb-labnk,        "Delivery schedule
            abrdt  LIKE vblb-abrdt,        "Deivery date
            gjkun LIKE vblb-gjkun,         "Current fiscal year
            vjkun LIKE vblb-vjkun,         "Previous fiscal year
          END   OF tbl_vblb_jit.
    Internal table to hold the Forecast Schedule lines
    DATA: BEGIN OF tbl_vbep_forecast OCCURS 0,
           vbeln LIKE vbep-vbeln,          "Sales document
           posnr LIKE vbep-posnr,          "Item number
           etenr LIKE vbep-etenr,          "Schedule line
           edatu LIKE vbep-edatu,          "Schedule line date
           ezeit LIKE vbep-ezeit,          "Arrival time       "DN3K923909
           wmeng LIKE vbep-wmeng,          "Order quantity in sales units
           prgrs LIKE vbep-prgrs, "Date type (day, week, month, interval)
           abart LIKE vbep-abart,          "Release type       "DN3K923909
          END   OF tbl_vbep_forecast.
    Internal table to hold the JIT Schedule lines
    DATA: BEGIN OF tbl_vbep_jit OCCURS 0,
           vbeln LIKE vbep-vbeln,          "Sales document
           posnr LIKE vbep-posnr,          "Item number
           etenr LIKE vbep-etenr,          "Schedule line
           edatu LIKE vbep-edatu,          "Schedule line date
           ezeit LIKE vbep-ezeit,          "Arrival time
           wmeng LIKE vbep-wmeng,          "Order quantity in sales units
           prgrs LIKE vbep-prgrs, "Date type (day, week, month, interval)
           abart LIKE vbep-abart,          "Release type      "DN3K923909
          END   OF tbl_vbep_jit.
    Internal table for Long texts
    DATA: tbl_tline  LIKE tline OCCURS 0 WITH HEADER LINE.
                    V A R I A B L E S                                   *
    DATA: v_count               TYPE i,
          V_REPID               LIKE SY-REPID,
          w_eins                LIKE vbap-umvkz VALUE 1,
          v_cumulative_deli_qty LIKE vblb-abefz,
          v_text_name           LIKE thead-tdname,
          v_week                LIKE scal-week,
          v_count_h             TYPE i,    "Count of header records
          v_count_f             TYPE i,    "Count of Forecast records
          v_count_j             TYPE i,    "Count of JIT records
          v_count_t             TYPE i.    "Count of Shipping instructions
    TYPES: unixfile LIKE rlgrap-filename,
           unixdir LIKE rlgrap-filename.
    DATA: v_file1 TYPE unixfile,
          v_file2 TYPE unixfile.
    DATA: tbl_dynpfields LIKE dynpread OCCURS 0 WITH HEADER LINE.
    *data  tbl_cust_sa.
          S E L E C T - O P T I O N S / P A R A M E T E R S             *
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
             Valid-to date
    PARAMETER:
              p_gueen like vbak-gueen obligatory,
             Correction Delivery date
               P_DELDT LIKE VBAK-GUEEN OBLIGATORY.
    Begin of Changes - TIR-40266
                  Plant
    SELECT-OPTIONS: s_werks FOR vbap-werks.
    *SD document category
    SELECT-OPTIONS: S_VBTYP FOR VBAK-VBTYP OBLIGATORY." Murali Poli
             Sales organization
    SELECT-OPTIONS: S_VKORG FOR VBAK-VKORG OBLIGATORY.
    End   of Changes - TIR-40266
    SELECTION-SCREEN SKIP 1.
    PARAMETER:      r1  RADIOBUTTON GROUP rg1.
             Material numbers file
    PARAMETER: P_FILE1 LIKE RLGRAP-FILENAME.
    PARAMETER: P_FILE6 LIKE RLGRAP-FILENAME.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT  1(32) text-003.
    SELECTION-SCREEN POSITION 33.
             SD SA Extract file
    PARAMETER: P_FILE2 LIKE RLGRAP-FILENAME
      DEFAULT 'C:\sd_sa_extract.txt'.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN SKIP 2.
    PARAMETER:      r2  RADIOBUTTON GROUP rg1.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT  1(32) text-004.
    SELECTION-SCREEN POSITION 33.
    PARAMETER: p_path1 TYPE unixdir OBLIGATORY DEFAULT '/tmp/'.
    SELECTION-SCREEN END OF LINE.
             Material numbers file
    PARAMETER: PU_FILE1 LIKE RLGRAP-FILENAME.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT  1(32) text-003.
    SELECTION-SCREEN POSITION 33.
             SD SA Extract file
    PARAMETER: PU_FILE2 LIKE RLGRAP-FILENAME.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT  1(64) text-005.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END   OF BLOCK b1.
            A T  S E L E C T I O N   S C R E E N   E V E N T S          *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file1.
      v_repid = syst-repid.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
           EXPORTING
                program_name  = v_repid
           CHANGING
                file_name     = p_file1
           EXCEPTIONS
                mask_too_long = 1
                OTHERS        = 2.
      IF sy-subrc <> 0.
        MESSAGE e009.
      Message shown as 'Error while getting the file name'
      ENDIF.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE6.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
           EXPORTING
                program_name  = v_repid
           CHANGING
                FILE_NAME     = P_FILE6
           EXCEPTIONS
                mask_too_long = 1
                OTHERS        = 2.
      IF sy-subrc <> 0.
        MESSAGE e009.
      Message shown as 'Error while getting the file name'
      ENDIF.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file2.
      v_repid = syst-repid.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
           EXPORTING
                program_name  = v_repid
           CHANGING
                file_name     = p_file2
           EXCEPTIONS
                mask_too_long = 1
                OTHERS        = 2.
      IF sy-subrc <> 0.
        MESSAGE e009.
      Message shown as 'Error while getting the file name'
      ENDIF.
    AT SELECTION-SCREEN ON RADIOBUTTON GROUP rg1.
      IF r1 = 'X'.
        IF  p_file1 = '' OR p_file2 = ''.
          MESSAGE w000 WITH 'Please select a PC file'.
        ENDIF.
        LOOP AT SCREEN.
          IF screen-name = 'P_FILE1' OR
             screen-name = 'P_FILE2'.
            screen-input = '1'.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ELSEIF r2 = 'X'.
        PERFORM get_value USING 'P_PATH1' CHANGING p_path1.
        PERFORM get_value USING 'PU_FILE1' CHANGING pu_file1.
        PERFORM get_value USING 'P_PATH1' CHANGING p_path1.
        PERFORM get_value USING 'PU_FILE2' CHANGING pu_file2.
        IF  pu_file1 = '' OR pu_file2 = ''.
          MESSAGE w000 WITH 'Please select a UNIX file'.
          LOOP AT SCREEN.
            IF screen-name = 'PU_FILE1' OR
               screen-name = 'PU_FILE2'.
              screen-input = '1'.
              MODIFY SCREEN.
            ENDIF.
          ENDLOOP.
        ENDIF.
      ENDIF.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR pu_file1.
      PERFORM get_value USING 'P_PATH1' CHANGING p_path1.
      PERFORM get_value USING 'PU_FILE1' CHANGING pu_file1.
      PERFORM popup_unix_filename CHANGING p_path1 pu_file1.
      PERFORM set_value USING 'P_PATH1' p_path1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR pu_file2.
      PERFORM get_value USING 'P_PATH1' CHANGING p_path1.
      PERFORM get_value USING 'PU_FILE2' CHANGING pu_file2.
      PERFORM popup_unix_filename CHANGING p_path1 pu_file2.
      PERFORM set_value USING 'P_PATH1' p_path1.
                     T O P - O F - P A G E                              *
    TOP-OF-PAGE.
    PERFORM delphi_header(z_delphi_header_footer)
         USING
         'E & S SD SCHEDULING AGREEMENTS EXTRACT DATA'(016)
          space
          sy-linsz.
               S T A R T - O F  - S E L E C T I O N                     *
    START-OF-SELECTION.
      IF r1 = 'X'.
        PERFORM upload_data_from_pc_files.
      ELSEIF r2 = 'X'.
        PERFORM upload_data_from_unix_files.
      ENDIF.
      PERFORM check_input_data.
      PERFORM get_sd_sa_data.
                   E N D - O F - S E L E C T I O N                      *
    END-OF-SELECTION.
      PERFORM process_data.
                        S U B - R O U T I N E S                          *
    *&      Form  get_value
    FORM get_value USING value(p_fieldname)
                CHANGING value(p_fieldvalue).
      IF v_repid IS INITIAL.
        v_repid = syst-repid.
      ENDIF.
      REFRESH: tbl_dynpfields.
      CLEAR: tbl_dynpfields.
      tbl_dynpfields-fieldname = p_fieldname.
      APPEND tbl_dynpfields.
      CALL FUNCTION 'DYNP_VALUES_READ'
           EXPORTING
                dyname               = v_repid
                dynumb               = '1000'
           TABLES
                dynpfields           = tbl_dynpfields
           EXCEPTIONS
                invalid_abapworkarea = 1
                invalid_dynprofield  = 2
                invalid_dynproname   = 3
                invalid_dynpronummer = 4
                invalid_request      = 5
                no_fielddescription  = 6
                invalid_parameter    = 7
                undefind_error       = 8
                double_conversion    = 9
                stepl_not_found      = 10
                OTHERS               = 11.
      IF syst-subrc = 0.
        READ TABLE tbl_dynpfields INDEX 1.
        p_fieldvalue = tbl_dynpfields-fieldvalue.
      ENDIF.
      REFRESH: tbl_dynpfields.
    ENDFORM.                               " get_value
          FORM POPUP_UNIX_FILENAME                                      *
    Pops up dialog box to explore the unix filesystem and select a file *
    -->  VALUE(P_PATH)      Path where to start exploring from         *
    -->  VALUE(P_FILENAME)  Default filename in the dialog box         *
    FORM popup_unix_filename CHANGING value(p_path) TYPE unixdir
                                      value(p_filename) TYPE unixfile.
    DATA: v_length TYPE i,
           v_filename TYPE unixfile,
           v_directory LIKE draw-filep,
           v_file LIKE draw-filep.
    IF p_filename(1) = '/'  OR
        p_path IS INITIAL.
       v_filename = p_filename.
    ELSE.
       v_length = strlen( p_path ) - 1.
       IF p_path+v_length(1) <> '/'.
         CONCATENATE p_path '/' INTO p_path.
       ENDIF.
       CONCATENATE p_path p_filename INTO v_filename.
    ENDIF.
    CALL FUNCTION 'Z_UNIX_FILENAME_GET'
          EXPORTING
               def_filename     = v_filename
               mask             = ',*.'
               mode             = 'G'
               title            = 'Get UNIX file...'
          IMPORTING
               filename         = v_filename
          EXCEPTIONS
               inv_winsys       = 1
               no_batch         = 2
               selection_cancel = 3
               selection_error  = 4
               OTHERS           = 5.
    CHECK syst-subrc = 0.
    CALL FUNCTION 'CV120_SPLIT_PATH'
          EXPORTING
               pf_path  = v_filename
          IMPORTING
               pfx_path = v_directory
               pfx_file = v_file
          EXCEPTIONS
               OTHERS   = 1.
    CHECK syst-subrc = 0.
    IF v_directory = p_path.
       p_filename = v_file.
    ELSE.
       p_filename = v_filename.
    ENDIF.
    ENDFORM.
          FORM SET_VALUE                                                *
    Sets the value of a field on the selection screen.                  *
    -->  VALUE(P_FIELDNAME)   Name of the field on the selection screen*
    -->  VALUE(P_FIELDVALUE)  Value of the field                       *
    FORM set_value USING value(p_fieldname)
                         value(p_fieldvalue).
      IF v_repid IS INITIAL.
        v_repid = syst-repid.
      ENDIF.
      CLEAR: tbl_dynpfields.
      tbl_dynpfields-fieldname = p_fieldname.
      tbl_dynpfields-fieldvalue = p_fieldvalue.
      APPEND tbl_dynpfields.
      CALL FUNCTION 'DYNP_VALUES_UPDATE'
           EXPORTING
                dyname               = v_repid
                dynumb               = '1000'
           TABLES
                dynpfields           = tbl_dynpfields
           EXCEPTIONS
                invalid_abapworkarea = 1
                invalid_dynprofield  = 2
                invalid_dynproname   = 3
                invalid_dynpronummer = 4
                invalid_request      = 5
                no_fielddescription  = 6
                undefind_error       = 7
                OTHERS               = 8.
    ENDFORM.
    *&      Form  upload_data_from_pc_files
    This subroutine is used to upload the data from input files
    FORM upload_data_from_pc_files.
      REFRESH: tbl_matnr.
      CLEAR:   tbl_matnr.
    Upload the data from Delphi Materials file
      CALL FUNCTION 'WS_UPLOAD'
           EXPORTING
                filename                = p_file1
                filetype                = 'DAT'
           TABLES
                data_tab                = tbl_matnr
           EXCEPTIONS
                conversion_error        = 1
                file_open_error         = 2
                file_read_error         = 3
                invalid_type            = 4
                no_batch                = 5
                unknown_error           = 6
                invalid_table_width     = 7
                gui_refuse_filetransfer = 8
                customer_error          = 9
                OTHERS                  = 10.
      IF sy-subrc <> 0.
        MESSAGE e008 WITH 'Materials file'.
      Message shown as "Error while reading Materials file"
      ENDIF.
      IF sy-subrc = 0 AND tbl_matnr[] IS INITIAL.
        MESSAGE e013 WITH 'Materials'.
      Message shown as "No records found in Materials file"
      ENDIF.
      DELETE tbl_matnr WHERE matnr = ''.
      CALL FUNCTION 'WS_UPLOAD'
           EXPORTING
                FILENAME                = P_FILE6
                filetype                = 'DAT'
           TABLES
                DATA_TAB                = TBL_CUST_SA
           EXCEPTIONS
                conversion_error        = 1
                file_open_error         = 2
                file_read_error         = 3
                invalid_type            = 4
                no_batch                = 5
                unknown_error           = 6
                invalid_table_width     = 7
                gui_refuse_filetransfer = 8
                customer_error          = 9
                OTHERS                  = 10.
      IF sy-subrc <> 0.
        MESSAGE E008 WITH 'Customer/Sales Area Cross Reference file'.
      Message shown as "Error while reading Materials file"
      ENDIF.
    ENDFORM.                               " upload_data_from_pc_files
    *&      Form  upload_data_from_unix_files
    This subroutine is used to upload the data from UNIX files
    FORM upload_data_from_unix_files.
      REFRESH: tbl_matnr.
      CLEAR:   tbl_matnr.
    Get the complete filename for the Materials file
      PERFORM get_full_filename USING pu_file1 CHANGING v_file1.
    Open the Materials file
      PERFORM open_dataset USING v_file1 'I' 'T' 1.
      CHECK syst-subrc = 0.
    Read the materials file
      DO.
        READ DATASET v_file1 INTO tbl_matnr.
        IF syst-subrc <> 0.
          EXIT.
        ENDIF.
    Populate the read data into the internal table
        APPEND tbl_matnr.
      ENDDO.
      PERFORM close_dataset USING v_file1.
    ENDFORM.                               " upload_data_from_unix_files
          FORM GET_FULL_FILENAME                                        *
    Uses the logical path if necessary to get the full filename         *
    If the filename already has a directory specified, that itself will *
      be the full filename                                              *
    Else the logical path for Conversions will be prefixed to the given *
      filename                                                          *
    FORM get_full_filename USING value(p_file) TYPE unixfile
                        CHANGING value(p_fullfile) TYPE unixfile.
      DATA: v_length TYPE i.
    IF p_file(1) = '/'  OR
        p_path1 IS INITIAL.
       p_fullfile = p_file.
    ELSE.
       v_length = strlen( p_path1 ) - 1.
       IF p_path1+v_length(1) = '/'.
         CONCATENATE p_path1 p_file INTO p_fullfile.
       ELSE.
         CONCATENATE p_path1 '/' p_file INTO p_fullfile.
       ENDIF.
    ENDIF.
    ENDFORM.
          FORM OPEN_DATASET                                             *
    Opens dataset in the specified mode                                 *
    -->  VALUE(P_FILE)    Name of file to be opened                    *
    -->  VALUE(P_IOMODE)  'I' for Input / 'O' for Output               *
    -->  VALUE(P_BTMODE)  'T' for Text / 'B' for Binary                *
    -->  VALUE(P_LEVEL)   If set to > 1, will write error message to   *
                           list Else will supress the error message but *
                           will be available in SYST-MSGV1              *
    FORM open_dataset USING value(p_file) TYPE unixfile
                            value(p_iomode) TYPE c
                            value(p_btmode) TYPE c
                            value(p_level) TYPE i.
      DATA: v_rc LIKE syst-subrc,
            v_msg(100),
            v_listmsg(100).
      IF p_iomode = 'O'.
        IF p_btmode = 'B'.
          OPEN DATASET p_file FOR OUTPUT IN BINARY MODE MESSAGE v_msg.
        ELSE.
          OPEN DATASET p_file FOR OUTPUT IN TEXT MODE MESSAGE v_msg.
        ENDIF.
      ELSE.
        IF p_btmode = 'B'.
          OPEN DATASET p_file FOR INPUT IN BINARY MODE MESSAGE v_msg.
        ELSE.
          OPEN DATASET p_file FOR INPUT IN TEXT MODE MESSAGE v_msg.
        ENDIF.
      ENDIF.
      IF syst-subrc <> 0.
        v_rc = syst-subrc.
        syst-msgv1 = v_msg.
        IF p_level > 0.
          CONCATENATE 'Unable to open' p_file
                 INTO v_listmsg
            SEPARATED BY space.
          IF p_iomode = 'O'.
            CONCATENATE v_listmsg 'for Output'
                   INTO v_listmsg
              SEPARATED BY space.
          ELSE.
            CONCATENATE v_listmsg 'for Input'
                   INTO v_listmsg
              SEPARATED BY space.
          ENDIF.
          IF p_iomode = 'B'.
            CONCATENATE v_listmsg 'in Binary mode'
                   INTO v_listmsg
              SEPARATED BY space.
          ELSE.
            CONCATENATE v_listmsg 'in Text mode'
                   INTO v_listmsg
              SEPARATED BY space.
          ENDIF.
          WRITE: / v_listmsg.
          WRITE: /3 '--', v_msg.
          syst-subrc = v_rc.
        ENDIF.
      ENDIF.
    ENDFORM.
          FORM CLOSE_DATASET                                            *
    Closes dataset                                                      *
    -->  VALUE(P_FILE)  Name of the file to be closed                  *
    FORM close_dataset USING value(p_file) TYPE unixfile.
      CLOSE DATASET p_file.
    ENDFORM.
    *&      Form  check_input_data
    This subroutine is used to check the data from X Ref files
    FORM check_input_data.
      DESCRIBE TABLE tbl_matnr LINES v_count.
    Use the material conversion routine to pad the material numbers
    with zeroes
      LOOP AT tbl_matnr.
        CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
             EXPORTING
                  input        = tbl_matnr-matnr
             IMPORTING
                  output       = tbl_matnr-matnr
             EXCEPTIONS
                  length_error = 1
                  OTHERS       = 2.
        TRANSLATE tbl_matnr-matnr TO UPPER CASE.
        MODIFY tbl_matnr.
      ENDLOOP.
    Get the materials from SAP database using the input materials
      IF NOT tbl_matnr[] IS INITIAL.
        SORT tbl_matnr BY matnr.
        SELECT matnr FROM mara
          INTO TABLE tbl_mara
           FOR ALL ENTRIES IN tbl_matnr
         WHERE matnr = tbl_matnr-matnr.
        SORT tbl_mara BY matnr.
      ENDIF.
    Check the existence of input materials in SAP database
      LOOP AT tbl_matnr.
        READ TABLE tbl_mara WITH KEY matnr = tbl_matnr-matnr
             BINARY SEARCH.
        IF sy-subrc <> 0.
          CONCATENATE 'Material' tbl_matnr-matnr 'does not exist'
                 INTO tbl_error-error_text
            SEPARATED BY space.
          APPEND tbl_error.
          CLEAR  tbl_error.
          DELETE tbl_matnr.
        ENDIF.
      ENDLOOP.
    ENDFORM.                               " check_input_data
    *&      Form  get_sd_sa_data
    This subroutine is used to get the SD Scheduling data from database
    FORM get_sd_sa_data.
    *begin of changes - DN3K923909
      DATA: tbl_vbep LIKE tbl_vbep_forecast OCCURS 0 WITH HEADER LINE,
            tbl_vblb LIKE tbl_vblb_forecast OCCURS 0 WITH HEADER LINE.
    *end of changes - ND3K923909
      REFRESH: tbl_vbap_vapma, tbl_vbpa, tbl_vblb_forecast,
               tbl_vblb_jit, tbl_vbep_forecast, tbl_vbep_jit.
      CLEAR:   tbl_vbap_vapma, tbl_vbpa, tbl_vblb_forecast,
               tbl_vblb_jit, tbl_vbep_forecast, tbl_vbep_jit.
    Get the Scheduling Agreements
      SELECT avbeln aposnr
           a~vgbel
             AAUART avkorg avtweg aspart a~kunnr
            a~ablfz
             A~MATNR
           a~pstyv
             a~werks
           a~lgort
            a~vstel
              ATRVOG BVBTYP BVSBED  BBSTNK B~KTEXT
        FROM VAPMA AS A INNER JOIN VBAK AS B
          ON bvbeln = avbeln
        INTO TABLE tbl_vbap_vapma
         FOR ALL ENTRIES IN tbl_mara
       WHERE a~matnr = tbl_mara-matnr
    Begin of Changes - TIR-40266
         AND a~vkorg IN s_vkorg
         AND a~werks IN s_werks
    End of Changes - TIR-40266
         AND A~TRVOG = '3'
         AND B~VBTYP IN S_VBTYP.           "Murali Poli
        and a~abgru = ''
        and b~gueen >= p_gueen.
      SORT tbl_vbap_vapma BY vbeln posnr.
      IF NOT tbl_vbap_vapma[] IS INITIAL.
        SELECT VBELN POSNR VGBEL ABLFZ PSTYV LGORT VSTEL FROM VBAP
         INTO TABLE  TBL_VBAP FOR ALL ENTRIES IN TBL_VBAP_VAPMA
           WHERE VBELN = TBL_VBAP_VAPMA-VBELN
            AND POSNR = TBL_VBAP_VAPMA-POSNR.
        LOOP AT TBL_VBAP_VAPMA.
          READ TABLE TBL_VBAP WITH KEY VBELN = TBL_VBAP_VAPMA-VBELN
                                       POSNR = TBL_VBAP_VAPMA-POSNR.
          IF SY-SUBRC = 0 .
            TBL_VBAP_VAPMA-VBELN  = TBL_VBAP-VBELN.
            TBL_VBAP_VAPMA-POSNR  = TBL_VBAP-POSNR.
            TBL_VBAP_VAPMA-VGBEL  = TBL_VBAP-VGBEL.
            TBL_VBAP_VAPMA-ABLFZ  = TBL_VBAP-ABLFZ.
            TBL_VBAP_VAPMA-PSTYV  = TBL_VBAP-PSTYV.
            TBL_VBAP_VAPMA-LGORT  = TBL_VBAP-LGORT.
            TBL_VBAP_VAPMA-VSTEL  = TBL_VBAP-VSTEL.
            MODIFY TBL_VBAP_VAPMA .
          ENDIF.
        ENDLOOP.
        tbl_vbap_vapma_temp[] = tbl_vbap_vapma[].
    *--Begin of UnCommentDIR-51476-DN3K932648
    -------------- Begin of Comment -----------  CCR-50124  DN3K928457
        SORT tbl_vbap_vapma_temp BY vbeln.
        DELETE ADJACENT DUPLICATES FROM tbl_vbap_vapma COMPARING vbeln.
    -------------- End of Comment -----------  CCR-50124  DN3K928457
    *--End of UnCommentDIR-51476-DN3K932648
    *--Begin of CommentDIR-51476-DN3K932648
    -------------- Begin of Insert -----------  CCR-50124  DN3K928457
    Duplicate Line Items are being deleted.
       SORT tbl_vbap_vapma BY vbeln posnr.
    DELETE ADJACENT DUPLICATES FROM tbl_vbap_vapma COMPARING vbeln posnr.
    The field for contract in SA is being modified for uniqueness
       loop at tbl_vbap_vapma.
         clear: v_vgbel, v_posnr.
         v_vgbel = tbl_vbap_vapma-vgbel.
         v_posnr = tbl_vbap_vapma-posnr.
         if not v_vgbel is initial .
           shift v_vgbel left deleting leading v_zero.
           shift v_posnr left deleting leading v_zero.
           v_posnr = v_posnr / 10.
           condense: v_vgbel, v_posnr.
           if v_posnr le 9.
             concatenate v_vgbel '0' v_posnr into v_vgbel.
           else.
             concatenate v_vgbel v_posnr into v_vgbel.
           endif.
         endif.
         tbl_vbap_vapma-vgbel = v_vgbel.
         modify tbl_vbap_vapma.
       endloop.
    -------------- End of Insert -----------  CCR-50124  DN3K928457
    *--End of CommentDIR-51476-DN3K932648
    Get the Partner details
       select vbeln posnr parvw kunnr
    *Start of Murali Poli
        SELECT VBELN POSNR INCO1 INCO2
               INTO TABLE TBL_VBKD
               FROM VBKD
               FOR ALL ENTRIES IN TBL_VBAP_VAPMA
               WHERE VBELN = TBL_VBAP_VAPMA-VBELN.
              and posnr  = tbl_vbap_vapma-posnr.
    *End of Murali Poli
        SELECT vbeln posnr parvw kunnr lifnr                    "DN3K923909
          INTO TABLE tbl_vbpa
          FROM vbpa
           FOR ALL ENTRIES IN tbl_vbap_vapma_temp
         WHERE vbeln = tbl_vbap_vapma_temp-vbeln
           AND parvw IN ('WE', 'SP').
    *begin of changes - DN3K923909
       select vbeln posnr abart abefz labnk abrdt gjkun vjkun
         into table tbl_vblb_forecast
         from vblb
          for all entries in tbl_vbap_vapma
        where vbeln = tbl_vbap_vapma-vbeln
          and posnr = tbl_vbap_vapma-posnr
          and abrli = '0000'
          and abart = '1'.
        SELECT vbeln posnr abart abefz labnk abrdt gjkun vjkun
          INTO TABLE tbl_vblb
          FROM vblb
           FOR ALL ENTRIES IN tbl_vbap_vapma
         WHERE vbeln = tbl_vbap_vapma-vbeln
           AND posnr = tbl_vbap_vapma-posnr
           AND abrli = '0000'
           AND abart IN ('1','2').
        SELECT vbeln posnr etenr edatu ezeit wmeng prgrs abart
          INTO TABLE tbl_vbep
          FROM vbep
           FOR ALL ENTRIES IN tbl_vbap_vapma
         WHERE vbeln = tbl_vbap_vapma-vbeln
           AND posnr = tbl_vbap_vapma-posnr
           AND abart IN ('1','2').
    Get the current Forecast delivery schedule
        tbl_vblb_forecast[] = tbl_vblb[].
        DELETE tbl_vblb_forecast WHERE abart = '2'.
    Get the current Forecast Schedule lines
        tbl_vbep_forecast[] = tbl_vbep[].
        DELETE tbl_vbep_forecast WHERE abart = '2'.
    Get the current JIT delivery Schedule
       select vbeln posnr abart abefz labnk abrdt gjkun vjkun
         into table tbl_vblb_jit
         from vblb
          for all entries in tbl_vbap_vapma
        where vbeln = tbl_vbap_vapma-vbeln
          and posnr = tbl_vbap_vapma-posnr

  • BAPI for Create PO from Sales Order Data and POST GR from PO created

    Dear,
             Can u help me how to create BAPI for Purchase Order creation from sales order Data
              what the bapi to Post GR from the PO created.
    Regards,
    Manoj

    Hello Manoj what you have to do to create PO from PR is that
    1) Use   BAPISDORDER_GETDETAILEDLIST (pass sales order number in sales_document table) and then get PR (Purchase requisition number from this BAPI.
    2) Use  BAPI_REQUISITION_GETDETAIL to get PR items
    3) Use BAPI_PO_CREATE1 to craete PO from PR then.
    to create goods movement you can use
    BAPI_GOODSMVT_CREATE
    REWARDS IF USEFUL.

  • Link between maintainance order reservation and pur requisition

    Dear Experts,
    I need link between maintainance order reservation number against a materials and purchase requisition raised against it.
    Basically requirement is that i need a report in which i can c the purchase requisition against the materials of maintanace order..
    Please help me out
    Regards,
    Vishal

    hey somebuddy will plz help me out ...

  • Sales Order Date and Despatch Advice Date

    Hi all,
    I need to create a view that contains Sales Order #, Despatch Advice # , Sales Order Date, Despatch Advice Date and Sales Organization. Please tell me that using which tables, required view can be created?
    Regards,
    AI.

    In table VBAK, you can take the fields Sales Organisation, po # & Date.
    What do you mean by Despatch Advice # ??  If you are referring to delivery which we generate in VL01N, you can make use of table LIKP for header level and LIPS for item level.
    thanks
    G. Lakshmipathi

  • API to create a link between Sales order and Requisition

    We are upgrade 11i to R12. We have a custom drop ship process. We have a original SO and through the sales order we create a Reqisition. We send the requisition details to the factory and the factory sends us a flat file with the quantity shipped and dates. There might be multiple lines for each requisition received. We will add the details to the SO and update the Requision with the flat file details for the SO shipment. But We will have to create a link between the SO and the requisition. Is there an API to do the linking between a SO and A requisition line?

    I created a SO and a requisition
    declare
    p_rsv inv_reservation_global.mtl_reservation_rec_type;
    p_dummy_sn inv_reservation_global.serial_number_tbl_type;
    x_msg_count NUMBER;
    x_msg_data VARCHAR2(240);
    x_rsv_id NUMBER;
    x_dummy_sn inv_reservation_global.serial_number_tbl_type;
    x_status VARCHAR2(1);
    x_qty NUMBER;
    l_inventory_item_id number;
    l_source_header_id number;
    l_reservation_qty number;
    l_error_message VARCHAR2(300);
    l_order_number NUMBER;
    begin
    fnd_global.APPS_Initialize(1131,50654,660);
    p_rsv.reservation_id := NULL;
    p_rsv.requirement_date := to_date('30-JUN-2012','DD-MON-YYYY');
    p_rsv.organization_id := 88; ---ship_from_org_id
    p_rsv.inventory_item_id := 147001; --inventory_item_id
    p_rsv.demand_source_type_id := inv_reservation_global.g_source_type_oe;
    p_rsv.demand_source_name := NULL;-------'SALES ORDER';
    p_rsv.demand_source_header_id := 27005; --- sales order header id
    p_rsv.demand_source_line_id := 29010; --- sales order line id
    p_rsv.primary_uom_code := 'EA';
    p_rsv.primary_uom_id := NULL;
    p_rsv.reservation_uom_code := 'EA';
    p_rsv.reservation_uom_id := NULL;
    p_rsv.reservation_quantity := 200;
    p_rsv.primary_reservation_quantity := 200;
    ----p_rsv.supply_source_type_id := inv_reservation_global.g_source_type_internal_req;
    p_rsv.supply_source_type_id :=inv_reservation_global.g_source_type_inv;
    p_rsv.supply_source_header_id :=18001; -- requisition header id
    p_rsv.supply_source_line_id :=12172; -- requisition line id
    p_rsv.supply_source_name := NULL;
    p_rsv.supply_source_line_detail := NULL;
    p_rsv.autodetail_group_id := NULL;
    p_rsv.external_source_code := NULL;
    p_rsv.external_source_line_id := NULL;
    p_rsv.supply_source_line_detail := NULL;
    p_rsv.revision := NULL;
    p_rsv.subinventory_code := NULL;
    p_rsv.subinventory_id := NULL;
    p_rsv.locator_id := NULL;
    p_rsv.lot_number := NULL;
    p_rsv.lot_number_id := NULL;
    p_rsv.pick_slip_number := NULL;
    p_rsv.lpn_id := NULL;
    p_rsv.attribute_category := NULL;
    p_rsv.ship_ready_flag := NULL;
    p_rsv.demand_source_delivery := NULL;
    p_rsv.attribute1 := NULL;
    p_rsv.attribute2 := NULL;
    p_rsv.attribute3 := NULL;
    p_rsv.attribute4 := NULL;
    p_rsv.attribute5 := NULL;
    p_rsv.attribute6 := NULL;
    p_rsv.attribute7 := NULL;
    p_rsv.attribute8 := NULL;
    p_rsv.attribute9 := NULL;
    p_rsv.attribute10 := NULL;
    p_rsv.attribute11 := NULL;
    p_rsv.attribute12 := NULL;
    p_rsv.attribute13 := NULL;
    p_rsv.attribute14 := NULL;
    p_rsv.attribute15 := NULL;
    inv_reservation_pub.create_reservation
    p_api_version_number => 1.0
    , x_return_status => x_status
    , x_msg_count => x_msg_count
    , x_msg_data => x_msg_data
    , p_rsv_rec => p_rsv
    , p_serial_number => p_dummy_sn
    , x_serial_number => x_dummy_sn
    , x_quantity_reserved => x_qty
    , x_reservation_id => x_rsv_id
    IF x_status='S' THEN --- HARD RESERVATION IS DONE SUCCESFULLY ---
    dbms_output.put_line('reservation succesful');
    dbms_output.put_line('reservation id: || x_rsv_id');
    ELSE
    if(nvl(x_msg_count,0) = 0) then
    dbms_output.put_line('no message return');
    else
    for I in 1..x_msg_count LOOP
    l_error_message := fnd_msg_pub.get(I, 'F');
    end LOOP;
    end if;
    --- HARD RESERVATION API fails ---
    dbms_output.put_line('Reservation API Error Message: '||l_error_message);
    END IF;
    EXCEPTION
    WHEN OTHERS THEN ------------------ In case of any pl/sql error
    l_error_message := SQLERRM;
    dbms_output.put_line('Plsql Error Message: '||l_error_message);
    END;
    but i am getting an error
    "Reservation API Error Message: INV_RSV_DS_SO"
    I am stuck and no idea how to fix this. Any help is appreciated.
    Edited by: 901524 on May 23, 2012 1:26 PM

  • Link between sales order and purchase order

    plz explain the link between the sales order and purchase request

    Hi Javed,
    Their are 2 scenario for this.
    1) You create a sales order and the system automatically creates a PR and then you convert to PO.This is third party sales.In PO account assignment the sales order number is directly copied to the PR And PO.
    2) You create a PO wrt to SO .The goods received will be reserved for that SO. third party PO Vendor will directly deliver the goods to customer.The delivery address is copied from sales order.
    Techincally
    EKKN table you have sales order and Item fields (VBELN and POSNR)
    using these fields search for the deliveries in LIPS table
    EKKN-VBELN = LIPS-VGBEL and
    EKKN-POSNR = LIPS-VGPOS
    Edited by: Raj on Jun 19, 2008 6:58 PM

  • Crystal report link between sales order and picklist

    Hi,
    Good day!
    I am making a picklist document using crysal report. My requirement is to show the sales order number, cardcode, cardname, itemcode, released qty in the picklist. the tables i linked in crystal are the ff:
    RDR1.DocEntry linked to ORDR.DocEntry and ORDR.DocNum linked to PKL1.OrderEntry.
    I have a sales order with 2 items and then I processed picklist for it. When I run the report, my problem is that it shows the items twice.
    Scenario:
    Sales Order 1:
    Item A   2
    Item B   1
    When I run the report, it's like this:
    Item A 2
    Item A 1
    Item B 2
    Item B 1
    I'd already tried adjusting the links but still can't get it.
    Please help me.
    Thanks so much.
    SIncerely,
    Jackilou

    Hi,
    could you please describe how you solve this issue?
    Thank you very much!
    Regards,
    Tobias

  • Different CUOBJ between sales order item and production order

    Hi gurus,
    Our SAP solution is IS Mill & Variant configuration based, we're using ECC6 as OLTP system mapped to APO PP/DS from which module we trigger the planned order into production order conversion. We're exclusively using the 2 different production type : MTO & MTS. When Sales order based (MTO), it was not possible so far to change the configuration of the production order since following Message no. CO661 was advising the data for the configuration was taken from the allocated SO:
    Here is an old thread we'd posted where we were requesting further details about above message: Message CO 661 - Characteristics values were copied - you can only display
    We recently upgraded SP level (SAP_BASIS) from 15 to 30 on ECC6 side, SAP Basis Component on SCM side has been remaining unchanged with release 700 level 016.
    We now observe the message is unexpectively NOT raising anymore so-that the configuration can be freely adjusted; reason seem to be a different CUOBJ between the SO and its production order; please not the issue do not take place when creating the production order directly from ECC6 through CO08.
    Would you please help to clarify the reason of such a behaviour? Thanks in advance.
    Remark: snote 1326891 has been patched but w/o any added value as it do not really apply (= CTP not used)
    BR,
    Pascal.

    UP
    Below as an illustration CUOBJ from VBAP versus CUOBJ from AFPO
    Both WO have been created from APO, difference is the first one was created prior our SP level upgrade. I have to admitt CUOBJ mechanism between ECC & APO is quite unclear, below CUOBJ found when reading planned order data with FM /SAPAPO/RRP_LC_ORDER_GET_DATA (reading executed prior conversion, same outcome when reading prior its creation)
    BR,
    Pascal.

  • Link between Purchase orders created and ORCM(Recommendation report)

    Hi,
    In purchase orders created from MRP recommendation report, we want to change the price, warehouse and some UDF's .For this functionality we are stopping the B1 functionality and adding the Purchase orders through our coding,In this scenario once the purchase order is added to B1 the same record should not be visible in MRP recommendation for creating the Purchase order again.
    we are not finding the link how can we update the ORCM table from were MRP recommendation is picking data to change the status field to "D" so that it will be not visible for creating purchase order again.
    Can any one please help in this issue.
    Thanks in Advance.
    Thanks & Regards,
    OmPrakash.
    Edited by: Om Prakash Akarapu on Dec 26, 2008 6:05 AM

    Hi
    in <b>EKKN</b> table you have sales order and Item fields (VBELN and POSNR)
    using these fields search for the deliveries in LIPS table
    EKKN-VBELN = LIPS-VGBEL and
    EKKN-POSNR = LIPS-VGPOS
    <b>Reward points for useful Answers</b>
    Regards
    Anji

Maybe you are looking for

  • G/L Account is Blank in 2LIS_03_UM

    Dear ALL, Good Morning, Datasource 2LIS_03_UM is not populating the G/L Account (SAKTO). Even when I fill the setup table, the field SAKTO is blank. Could anyone suggest me from which table this field will be populated because we have requirement to

  • Is there a way to track the time within the clip (not sequence) that you're in?

    Let me try to explain this as best I can and make sense. I watched a video clip and I liked everything from, let's say the :30 mark to the minute mark. So, I import it into Premiere. However, when I put it at the end of the next clip, it shows the ti

  • Steps to build a compete OAF application

    Hi , I have a problem in creating an OAF application in JDeveloper,i'm new to this technology ,i've to create an application to consult a database and i dont know the steps i should follow (creating workspace ,project,bc4j.....) i know them but i don

  • 2 Macs running OS 10.4 are printing 2 copies of a single doc.

    I'm not much a Mac person so I need some assistance. There are 2 Macs that print to a new Sharp MX350N copier and when each prints, they are getting 2 copies of a single page doc. The copier tech said it was a Mac issue. I have deleted the printer (i

  • When will Lightroom enable importing RAF files from Fuji X100T?

    Just got my new X100T but Lightroom 5.6 does not yet enable importing RAF files. When will this be available?