Procurement Card data upload from flat file to database

Hi All,
I need to upload Procurement Card data from a flat file to the database in the table BBP_PCMAS.
I found a BAPI BAPI_PCARD_CREATEMULTIPLE which uploads the data perfectly, however the structure PCMASTER that it takes as input does not contain the field for Blocking reason PCBLOCK - Reason for blocking procurement card. I need to upload this file as well from the flat file.
Any suggestions?
Thanks

Hi,
You are correct the function module BAPI_PCARD_CREATEMULTIPLE  does not contain the PCBLOCK field.
Alternatively what you can do is read the PC data after it is created and modify it with the PCBLOCK appropiately. The necessary function modules are given below.
BBP_PCMAS_READ_PCMAS - Read Data
BBP_PCMAS_MODIFY_PCMAS - Modify Data
Note: BBP_PCMAS_MODIFY_PCMAS is a Update Task FM. Hence it shoild be called as given below, ( refer form write_data of the FM BAPI_PCARD_CREATEMULTIPLE)
  call function 'BBP_PCMAS_MODIFY_PCMAS' in update task
       exporting
            i_pcmas     = i_pcmas
*         I_PCMAS_OLD =
*         I_DELETE    =
      tables
           t_pcacc     = i_pcacc
*         T_PCACC_OLD =
      exceptions
           not_found   = 1
           others      = 2.
Regards
Kathirvel

Similar Messages

  • Va31 shedule line agreement data upload from flat file

    Hi abapers
    I have to upload some data (va31) from flat file to my database (shedule line agreement data) I am using user exit for it...Cant get which user exit will solve the purpose and where to check it from..I tried using SDTRM001 , meeta001 and and the va45A series but its not working. I used break point on these user exits but its not stoping at break point.
    Can any one help me where to find which user exit will work in this case?
    Thanks in Advance
    Annu

    Hi Prash,
    Check these posts:
    Re: Increasing the length of Infoobject from 60 to 240 characters
    Re: InfoObject > 60
    Bye
    Dinesh

  • Error occurred in the data uploading from Flat File in BPC NW

    Hi,
    I am doing Migration project from BPC MS to NW.
    In this i am loading data from flat file to BPC NW. One error occured in this process that is Record Duplication.
    Total 17000 records in that  7000 recards rejected by the reason of duplication.
    The Information about Package Log
    /CPMB/MODIFY completed in 0 seconds
    /CPMB/CONVERT completed in 2 seconds
    /CPMB/LOAD completed in 7 seconds
    /CPMB/CLEAR completed in 0 seconds
    [Selection]
    FILE= DATAMANAGER\DATAFILES\Aprilmayjun_2011_Budget_V1.CSV
    TRANSFORMATION= DATAMANAGER\TRANSFORMATIONFILES\ZAPRMAYJUN_2011BUDGET.xls
    CLEARDATA= No
    RUNLOGIC= Yes
    CHECKLCK= No
    [Messages]
    Task name CONVERT:
    No 1 Round:
    Record count: 17064
    Accept count: 17064
    Reject count: 0
    Skip count: 0
    Task name LOAD:
    Reject count: 7230
    Submit count: 9834
    Application: CorpBudget Package status: WARNING
    Could you help me in this at the earliest.
    Thanks and Regards
    Krishna

    Hi,
    You cannot send the duplicated with the standard import package. You need to create or add a new package and link to /CPMB/APPEND process chain and do the import. This would consider the duplicate entries also. It looks like you need somehow load all the records including the duplicate ones.
    So on excel go to Manage Data -> Maintain Data management -> organize package list and add a new package and link to the standard BPC process chain /CPMB/APPEND.
    Thanks,
    Sreeni

  • Data loading from flat file to cube using bw3.5

    Hi Experts,
                       Kindly give  me the detailed steps with screens  about Data loading from flat file to cube using bw3.5
           ...............Please

    Hi ,
    Procedure
    You are in the Data Warehousing Workbench in the DataSource tree.
           1.      Select the application components in which you want to create the DataSource and choose Create DataSource.
           2.      On the next screen, enter a technical name for the DataSource, select the type of DataSource and choose Copy.
    The DataSource maintenance screen appears.
           3.      Go to the General tab page.
                                a.      Enter descriptions for the DataSource (short, medium, long).
                                b.      As required, specify whether the DataSource builds an initial non-cumulative and can return duplicate data records within a request.
                                c.      Specify whether you want to generate the PSA for the DataSource in the character format. If the PSA is not typed it is not generated in a typed structure but is generated with character-like fields of type CHAR only.
    Use this option if conversion during loading causes problems, for example, because there is no appropriate conversion routine, or if the source cannot guarantee that data is loaded with the correct data type.
    In this case, after you have activated the DataSource you can load data into the PSA and correct it there.
           4.      Go to the Extraction tab page.
                                a.      Define the delta process for the DataSource.
                                b.      Specify whether you want the DataSource to support direct access to data.
                                c.      Real-time data acquisition is not supported for data transfer from files.
                                d.      Select the adapter for the data transfer. You can load text files or binary files from your local work station or from the application server.
    Text-type files only contain characters that can be displayed and read as text. CSV and ASCII files are examples of text files. For CSV files you have to specify a character that separates the individual field values. In BI, you have to specify this separator character and an escape character which specifies this character as a component of the value if required. After specifying these characters, you have to use them in the file. ASCII files contain data in a specified length. The defined field length in the file must be the same as the assigned field in BI.
    Binary files contain data in the form of Bytes. A file of this type can contain any type of Byte value, including Bytes that cannot be displayed or read as text. In this case, the field values in the file have to be the same as the internal format of the assigned field in BI.
    Choose Properties if you want to display the general adapter properties.
                                e.      Select the path to the file that you want to load or enter the name of the file directly, for example C:/Daten/US/Kosten97.csv.
    You can also create a routine that determines the name of your file. If you do not create a routine to determine the name of the file, the system reads the file name directly from the File Name field.
                                  f.      Depending on the adapter and the file to be loaded, make further settings.
    ■       For binary files:
    Specify the character record settings for the data that you want to transfer.
    ■       Text-type files:
    Specify how many rows in your file are header rows and can therefore be ignored when the data is transferred.
    Specify the character record settings for the data that you want to transfer.
    For ASCII files:
    If you are loading data from an ASCII file, the data is requested with a fixed data record length.
    For CSV files:
    If you are loading data from an Excel CSV file, specify the data separator and the escape character.
    Specify the separator that your file uses to divide the fields in the Data Separator field.
    If the data separator character is a part of the value, the file indicates this by enclosing the value in particular start and end characters. Enter these start and end characters in the Escape Charactersfield.
    You chose the; character as the data separator. However, your file contains the value 12;45 for a field. If you set u201C as the escape character, the value in the file must be u201C12;45u201D so that 12;45 is loaded into BI. The complete value that you want to transfer has to be enclosed by the escape characters.
    If the escape characters do not enclose the value but are used within the value, the system interprets the escape characters as a normal part of the value. If you have specified u201C as the escape character, the value 12u201D45 is transferred as 12u201D45 and 12u201D45u201D is transferred as 12u201D45u201D.
    In a text editor (for example, Notepad) check the data separator and the escape character currently being used in the file. These depend on the country version of the file you used.
    Note that if you do not specify an escape character, the space character is interpreted as the escape character. We recommend that you use a different character as the escape character.
    If you select the Hex indicator, you can specify the data separator and the escape character in hexadecimal format. When you enter a character for the data separator and the escape character, these are displayed as hexadecimal code after the entries have been checked. A two character entry for a data separator or an escape sign is always interpreted as a hexadecimal entry.
                                g.      Make the settings for the number format (thousand separator and character used to represent a decimal point), as required.
                                h.      Make the settings for currency conversion, as required.
                                  i.      Make any further settings that are dependent on your selection, as required.
           5.      Go to the Proposal tab page.
    This tab page is only relevant for CSV files. For files in different formats, define the field list on the Fields tab page.
    Here you create a proposal for the field list of the DataSource based on the sample data from your CSV file.
                                a.      Specify the number of data records that you want to load and choose Upload Sample Data.
    The data is displayed in the upper area of the tab page in the format of your file.
    The system displays the proposal for the field list in the lower area of the tab page.
                                b.      In the table of proposed fields, use Copy to Field List to select the fields you want to copy to the field list of the DataSource. All fields are selected by default.
           6.      Go to the Fields tab page.
    Here you edit the fields that you transferred to the field list of the DataSource from the Proposal tab page. If you did not transfer the field list from a proposal, you can define the fields of the DataSource here.
                                a.      To define a field, choose Insert Row and specify a field name.
                                b.      Under Transfer, specify the decision-relevant DataSource fields that you want to be available for extraction and transferred to BI.
                                c.      Instead of generating a proposal for the field list, you can enter InfoObjects to define the fields of the DataSource. Under Template InfoObject, specify InfoObjects for the fields in BI. This allows you to transfer the technical properties of the InfoObjects into the DataSource field.
    Entering InfoObjects here does not equate to assigning them to DataSource fields. Assignments are made in the transformation. When you define the transformation, the system proposes the InfoObjects you entered here as InfoObjects that you might want to assign to a field.
                                d.      Change the data type of the field if required.
                                e.      Specify the key fields of the DataSource.
    These fields are generated as a secondary index in the PSA. This is important in ensuring good performance for data transfer process selections, in particular with semantic grouping.
                                  f.      Specify whether lowercase is supported.
                                g.      Specify whether the source provides the data in the internal or external format.
                                h.      If you choose the external format, ensure that the output length of the field (external length) is correct. Change the entries, as required.
                                  i.      If required, specify a conversion routine that converts data from an external format into an internal format.
                                  j.      Select the fields that you want to be able to set selection criteria for when scheduling a data request using an InfoPackage. Data for this type of field is transferred in accordance with the selection criteria specified in the InfoPackage.
                                k.      Choose the selection options (such as EQ, BT) that you want to be available for selection in the InfoPackage.
                                  l.      Under Field Type, specify whether the data to be selected is language-dependent or time-dependent, as required.
           7.      Check, save and activate the DataSource.
           8.      Go to the Preview tab page.
    If you select Read Preview Data, the number of data records you specified in your field selection is displayed in a preview.
    This function allows you to check whether the data formats and data are correct.
    For More Info:  http://help.sap.com/saphelp_nw70/helpdata/EN/43/01ed2fe3811a77e10000000a422035/content.htm

  • Error in Data upload through Flat files in SAP BPC

    Hi,
    we are trying to upload data from flat files in SAP BPC  but an error is coming viz Object reference not set to an instance of an object .

    Hi,
    Can you please cross check the file structure and the transfer structure.
    Cheers,
    Malli....

  • Vendor master data load from flat file

    Hi Experts,
    I am trying to load data from flat file. I am confused which info object i should use. My requirement is for info cube 0BBP_C01.
    As i found for this info cube only two info objects are available: 0BBP_VENDOR and 0VENDOR. But in my flat file i have following fields: Vendor code, Vendor Name, Ultimate Parent, City, Country, Minority Status, Vendor Payment Terms. which all are together not present in either of info objects.
    Please suggest which info object i must use. or should i create Z info object for my requirement?
    Thanks in advance.
    Regards,
    Niranjan Chechani

    Hi Kiran,
    I am loading data through flat file. I am not getting your point like how to get attributes present in the R/3 system which I am not using in this case.
    Hi rvc,
    I have created two characteristics z info objects i.e. ZU_PARENT for Ultimate parent and ZVEN_PAY for Vendor Payment Terms.
    When i am trying to add these two as attributes and add it as Navigational attribute, I am getting the error "Characteristic 0VENDOR: The attibutes SID table(s) could not be filled" (Message no. R7586)
    Please suggest am i wrong somewhere?
    Thanks and Regards,
    Niranjan Chechani
    Edited by: Niranjan Chechani on Nov 28, 2011 12:15 PM

  • Help Required regding: Validation on Data Loading from Flat File

    Hi Experts,
    I need u r help in the following issue.
    I need to validated the transactional data loading to the GL Cube from Flat file,
    1) The transactional data to the Cube to be loaded <b>only if master data</b> record exists for the <b>“0GL_ACCOUNT”</b> info object.
    2) If the master data record does not exits then the record need to be skipped from the loading and after the loading  the system should throw a message saying that these many records have been skipped (if there are any skipped records.).
    I would really appriciate u r help and suggestions on solving this issue.
    Regds
    Hari

    Hi, write a <b>start routine</b> in transfer rules like this.
      DATA: l_s_datapak_line type TRANSFER_STRUCTURE,
            l_s_errorlog TYPE rssm_s_errorlog_int,
            <b>l_s_glaccount type /BI0/PGLACCOUNT</b>,
            new_datapak type tab_transtru.
           refresh new_datapak.
           loop at datapak into l_s_datapak_line.
           select single * from /BI0/PGLACCOUNT into l_s_glaccount
             where CHRT_ACCTS eq l_s_datapak_line-<b>field name in transfer structure/datsource for CHRT_ACCTS</b>
    and GL_ACCOUNT eq l_s_datapak_line-<b>field name in transfer structure/datsource for GL_ACCOUNT</b>
    and OBJVERS eq 'A'.
           if sy-subrc eq 0.
             append l_s_datapak_line to new_datapak.
           endif.
           endloop.
           datapak = new_datapak.
           if datapak[] is initial.
    abort <> 0 means skip whole data package !!!
             ABORT = 4.
           else.
             ABORT = 0.
           endif.
    i have already some modifications but U can slightly change it to suit your need.
    regards
    Emil

  • Cube creation & Data loading from Flat file

    Hi All,
    I am new to BI 7. Trying to create a cube and load data from a flat file.
    Successfully created the infosource and Cube (used infosource as a template for cube)
    But got stucked at that point.
    I need help on how to create transfer rules/update rules and then load data into it.
    Thanks,
    Praveen.

    Hi
    right click on infosource->additional functions->create transfer rules.
    now in the window insert the fields you want to load from flat file->activate it.
    now right click on the cube->additional functions->create update rules->activate it.
    click on the small arrow on the left and when you reach the last node(DS)
    right click on it->create info package->extenal data tab->give your FLAT file path and select csv format->schedule tab->click on start.
    hope it helps..
    cheers.

  • CUNIT error in data loading from flat file after r/3 extraction

    Hi all
    After R/3 business content extraction, if i load data from flat file to info cube, I am getting Conversion exit CUNIT error, what might be the reason, the data in the flat file 0unit column is accurate, and mapping rules are also correct, but still i am getting error with CUNIT.?

    check your unit if you are loading amount or quantities what mapping you have and what you are loading from flat files.
    BK

  • Data updation from flat file to I.C. via ODS

    Hi,
    I have to load transaction data from 4 tables into 4 ods and these 4 ods data will be loaded to 1 info cube.so please tell me the best method whether to use 4 info sources for 4 ods or can i define all the info objects in one info source and use the same info source for all ods objects.
    Thank you

    Hello GanGa,
    How r u ?
    1st could u tell, the loads are from Flat File or Tables ?
    coz ur Subject and the Message is getting clashed.
    If u use Flat Files, then better go for 4 IS and 1 ODS is enough. Then update the cube.
    If u r going to extract from Tables, then you have to create the Data Source using "Extraction from Views", for this u should have common key fields in all the 4 tables. In BW DataSource to InfoSource mapping should be 1 to 1.
    Best Regards....
    Sankar Kumar
    +91 98403 47141

  • Data loading from flat file into bw

    Hi Experts,
    When we load data from flat file into BW the <b>sequence of fields in flat file</b> should be matched with the <b>transfer structure</b> or <b>communication structure</b>?
    wid thanX,
    arijit

    Arijit,
    The sequence of fields in a flat file must be the same as this one in the transfer structure.
    The comm and tran structures are the same after the first creation of datasource from flat file source system. After that someone could change the sequence in the CS -- if the mapping of fields in transfer rules remains unchanged, then the load is to be succesful.
    In case of changing the sequence in TS you'll get either error or wrong load (values to be loaded into some infobjects will go to another ones.)
    Best regards,
    Eugene

  • Regarding master data ,transactional data loading from flat file

    Hi friends,
    Please tell me how to load master data and transactional data from flat file ....
    Thanks in advance ,
    Regards,
    ramnaresh.

    Hi,
    Please use the 'search forum' functionality and search the BI Forum with say 'flat file loading'.  You would get plenty of links of previous threads.
    BR/
    Mathew.

  • Steps to create Data loading from Flat File to Info Cube in BI

    Hi,
         I am very new BW, I need some one help. When I am trying to create info source i am any pop window stating to create Transaction data or master data.
         After creating Info source, I dont know how to assign this info source to source system (which i created).
          When select the context menu of info source I dont have option to assign the datasource.
          And one more thing is When I am creating the Info Cube. I cant understand how to create.
          Please some one help me how to map the fields to Source system.
    Regds
    Dave.

    Hi,
    For flat file upload, first you need to create the source system.
    Then you need to create the infosource based on the format of the flat file you are going to upload or vice versa depending on your requirements.
    Once your infosource is ready, right click on it and select assign datasource. Here you can assign your flat file datasource. Then create an infopackage and give the path from where the file is to be upload to BW (in the infopackage).
    Also look at the thread below for procedure on flat file upload :
    http://help.sap.com/saphelp_nw04s/helpdata/en/8e/dbe92341c84242be2c7d3917f1c197/frameset.htm
    Cheers,
    Kedar

  • BDC Uploading from flat file to VA01.

    i have a flat file, where i have to upload data  into VA01, but it should suppose to multiple materials under same customer and it should not get saved until end user decide whether data is ok or not. my problem is, how to make multiple entries of diff materials in VA01 for single customer. Please give me any solution, and if possible provide me any examples. thank you.

    Hi Kalyan,
    Here is the sample code for you ....... but i tis better you use the BAPI
    <b>BAPI_SALESORDER_CREATEFROMDAT1 or BAPI_SALESORDER_CREATEFROMDAT2</b>
    REPORT ZSD00001 MESSAGE-ID ZZ.
    TABLES: VBAK, VBAP.
    TABLES: ZSOM1, ZSOM2.
    SELECTION-SCREEN: BEGIN OF BLOCK FORT WITH FRAME TITLE TEXT-002.
    PARAMETERS: P_FILE RADIOBUTTON GROUP B2 DEFAULT 'X',
                P_TABLE RADIOBUTTON GROUP B2,
                P_REPORT RADIOBUTTON GROUP B2.
    SELECTION-SCREEN SKIP 1.
    PARAMETER: VIEW RADIOBUTTON GROUP VIEW,
               ERRORS RADIOBUTTON GROUP VIEW,
               NO_DIS RADIOBUTTON GROUP VIEW DEFAULT 'X'.
    SELECTION-SCREEN: END OF BLOCK FORT.
    SELECTION-SCREEN: BEGIN OF BLOCK FILE WITH FRAME TITLE TEXT-001.
    PARAMETERS:
                IDLEX RADIOBUTTON GROUP B1 DEFAULT 'X',
                DBLEX RADIOBUTTON GROUP B1,
                BDC_NAME(12)     TYPE C DEFAULT 'idllapso',
                IDLH(99)         TYPE C DEFAULT
            '/usr/sap/D01/DVEBMGS00/ISAP/interfaces/laptop/in/idlordht.txt',
                IDLI(99)         TYPE C DEFAULT
            '/usr/sap/D01/DVEBMGS00/ISAP/interfaces/laptop/in/idlordit.txt',
                ARC_FIL DEFAULT ' ' AS CHECKBOX.
    SELECTION-SCREEN: END OF BLOCK FILE.
    SELECTION-SCREEN: BEGIN OF BLOCK TAB WITH FRAME TITLE TEXT-003.
    SELECT-OPTIONS: O_IHREZ FOR ZSOM1-IHREZ,
                    O_VBELN FOR ZSOM1-IHREZ,
                    O_MESS FOR ZSOM1-MESS DEFAULT 'W'.
    SELECTION-SCREEN: END OF BLOCK TAB.
    DATA:
    * Data counters.
           RECS_IN(4)            TYPE N  VALUE 0,
           BDC_RECS_OUT(4)       TYPE N  VALUE 0,
           BDC_RECS_ERR(4)       TYPE N  VALUE 0,
           DATA_IN_RECS(4)        TYPE N  VALUE 0,
    * Data constants
           TRUE(1)               TYPE C  VALUE 'X',
           FALSE(1)              TYPE C  VALUE ' ',
    * Data variables
           ABAPNAME              LIKE SY-REPID,
           ABAPTITLE             LIKE SY-TITLE,
           SAVE_UCOMM            LIKE SY-UCOMM,
           V_IHREZ               LIKE VBAK-IHREZ.
    * inbound header structure
    DATA: BEGIN OF IDLORDH OCCURS 1000,
    SO-NUMBER(5)          TYPE N,  "The order number given by the Vax - Alwa
    ORDER-TYPE(1)         TYPE N,  "1 - Under-Bond Sale  3 - Duty-Paid Order
    CUST-NO(7)            TYPE N,          "Id for customer
    BRANCH-NO(4)          TYPE N,          "Id of customer's branch
    PC-DATE-REQD(8)       TYPE C,  "Date that customer required the order
    IDL-ORDER-NO(5)       TYPE N,          "Laptop's Order Number
    SPEC-INS-1(40)        TYPE C,  "Text detailing special instruction for t
    SPEC-INS-2(40)        TYPE C,          "Part 2 of above
    PC-ORDER-DATE(8)      TYPE C,  "Date order was entered on the Laptop
    ORDER-METHOD(1)       TYPE N,          "Always 5 for laptop
    FOR-COLLECTION(1)     TYPE C,  "Y if customers is collecting order else
    CASH-RECEIVED(9)      TYPE N,          "N/A
    CASH-SHEET-NO(6)      TYPE N,          "N/A
    CUST-ORDER-NO(14)     TYPE C,  "Customers Order Number - Optional
    HOLD-FOR-PRICING(1)   TYPE C,  "Y if this order is held because no price
    PC-PRICE-EFF-DATE(8)  TYPE C,          "Defaults to order date
    NO-ITEMS(4)           TYPE N,  "Number of items for this order in detail
    TOTAL-QTY-ORDERED(9)  TYPE N,          "Number of cases on this order
    TOTAL-CE-ORDERED(9)   TYPE N,  "Number of case equivalents on this order
    ORDER-STATUS(1)       TYPE N,          "Always 0 for new orders
    SITE-PREFIX(1)        TYPE C,  "Plant from where the delivery will be ma
    PC-USER-NO(3)         TYPE N.          "laptop user who crested order
    DATA: END OF IDLORDH.
    DATA: BEGIN OF IDLORDI OCCURS 1000,
    SO-NUMBER(5)         TYPE N,  "The order number given by the Vax - Alway
    ORDER-ENTRY-CODE(5)  TYPE N,           "Part Id
    PC-DATE-REQD(8)      TYPE C,  "Date the customer required order.
    QTY-TO-ORDER(4)      TYPE N,           "Number of units on the order.
    PC-USER-NO(3)        TYPE N,           "Id of rep. Who created the order
    IDL-ORDER-NO(5)      TYPE N,           "Laptop's Order Number
    FREE-QTY-ORDERED(4)  TYPE N,  "Number of free units on the order.
    PROMOTION-NO(4)      TYPE N.  "If Free units on the order, this is promo
    DATA: END OF IDLORDI.
    * Internal table to hold the mapped data.
    DATA:  BEGIN OF DATA_IN OCCURS 1000,
              RTYPE(1) TYPE C,
    * header
              AUART LIKE VBAK-AUART,       "order type
              VKORG LIKE VBAK-VKORG,       "sales org
              VTWEG LIKE VBAK-VTWEG,       "dist.channel
              SPART LIKE VBAK-SPART,       "division
              KUNNR LIKE KUAGV-KUNNR,      "customer num
    *         vkbur like vbak-vkbur,  "sales off
    *         vkgrp like vbak-vkgrp,  "sales grp
              BSTNK LIKE VBAK-BSTNK,       "po num
              IHREZ LIKE VBAK-IHREZ,       "po reference
              BSTDK LIKE VBAK-BSTDK,       "po date
              KPRGBZ  LIKE RV45A-KPRGBZ,   "date type
    *         ketdat  like rv45a-ketdat, "req delivery date
              KETDAT(8) TYPE C         ,   "req delivery date
              PRSDT    LIKE VBKD-PRSDT,    "pricing date
              LIFSK   LIKE VBAK-LIFSK,     "delivery block
              INCO1   LIKE  VBKD-INCO1,    "inco terms
              INCO2   LIKE VBKD-INCO2,     "inco descript.
              FAKSK   LIKE VBAK-FAKSK,     "biling block
              KUNDE   LIKE RV02P-KUNDE,    "shipto
              ltext1(256) type c,          "Special text1
              ltext2(256) type c,          "Special text2
              BSARK    LIKE VBAK-BSARK,    "ordering method
              BNAME    LIKE VBAK-BNAME,    "orderer
              WERKS LIKE VBAP-WERKS,       "Site Prefix
    * item
              POSNR LIKE VBAP-POSNR,       "item
              MATNR LIKE VBAP-MATNR,       "material
              MENGE(15) TYPE C,                                 "qty
              FREE_MENGE(15) TYPE C,       "Free qty ordered
              PSTYV LIKE VBAP-PSTYV,       "item category
              ROUTE LIKE VBAP-ROUTE,       "Collect or not
    *         vrkme(3) type c,        "uom
    *         itext(40),              "item txt
    END OF DATA_IN.
    DATA: BEGIN OF I_MATERIAL OCCURS 0,
          MATNR LIKE MARA-MATNR,
          ORDER LIKE IDLORDI-ORDER-ENTRY-CODE,
          END OF I_MATERIAL.
    DATA: BEGIN OF I_MAIL OCCURS 0.
          INCLUDE STRUCTURE SOLI.
    DATA: END OF I_MAIL.
    * Internal table to contain BDC data.
    DATA: BEGIN OF BDCDATA OCCURS 1000.
            INCLUDE STRUCTURE BDCDATA.
    DATA: END OF BDCDATA.
    DATA: BEGIN OF MESSTAB OCCURS 0.
            INCLUDE STRUCTURE BDCMSGCOLL.
    DATA: END OF MESSTAB.
    DATA: BEGIN OF I_OUTPUT OCCURS 1000.
            INCLUDE STRUCTURE DATA_IN.
    DATA: END OF I_OUTPUT.
    DATA: OLD_RTYPE LIKE DATA_IN-RTYPE,
          V_VBELN LIKE VBAK-VBELN,
          V_ITEM_NO(2) TYPE N,
          V_MAIL(1) TYPE C,
          V_VIEW(1) TYPE C,
          V_IDL-ORDER-NO LIKE IDLORDH-IDL-ORDER-NO,
          V_PC-USER-NO LIKE IDLORDH-PC-USER-NO.
    AT SELECTION-SCREEN.
    * Check name of BDC session has been supplied.
      IF BDC_NAME EQ SPACE.
        SET CURSOR FIELD 'BDC_NAME'.
        MESSAGE E002 WITH 'No batch-input session name supplied'.
      ENDIF.
    START-OF-SELECTION.
      MOVE: SY-REPID TO ABAPNAME,
            SY-TITLE TO ABAPTITLE.
      IF VIEW  = 'X'. V_VIEW = 'A'. ENDIF.
      IF ERRORS  = 'X'. V_VIEW = 'E'. ENDIF.
      IF NO_DIS  = 'X'. V_VIEW = 'N'. ENDIF.
      IF P_FILE = 'X'.
    * Read the input files.
        PERFORM READ_FILES.
    * Map the data.
        PERFORM MAP_DATA.
    * Create the BDC sessions.
        PERFORM CREATE_BDC_SESSIONS.
      MESSAGE I002 WITH 'Run the Report to check which orders have been
                                                                CREATED'.
      ELSEIF P_TABLE = 'X'.
       V_VIEW = 'A'.
    * Load Data from table.
        PERFORM F_TABLE_LOAD.
    * Create the BDC sessions.
        PERFORM CREATE_BDC_SESSIONS.
      MESSAGE I002 WITH 'Run the Report to check which orders have been
                                                                CREATED'.
      ELSEIF P_REPORT = 'X'.
    *Submit report.
       SUBMIT ZSDRLAPS AND RETURN
       USING SELECTION-SETS OF PROGRAM 'ZSDILAPT'
        WITH O_IHREZ IN O_IHREZ
        WITH O_VBELN IN O_VBELN
        WITH O_MESS IN O_MESS.
      ENDIF.
    * Archive the input file.
      IF ARC_FIL NE SPACE.
        PERFORM DEL_INP_FILE.
      ENDIF.
    IF V_MAIL = 1.
    MOVE 'CTRL F6 to Execute the LAPTOP Error log Program' TO I_MAIL-LINE.
    APPEND I_MAIL.
    CLEAR I_MAIL.
       CALL FUNCTION 'Z_SEND_MESSAGE'
            EXPORTING
                 MAIL_TO        = 'LAPTOPS'
                 MAIL_TITLE     = 'LAPTOP SALES ORDERS'
                 ATTACH_TYPE    = 'R'
                 NAME           = 'ZSDRLAPS'
            TABLES
                 CONTENTS       = I_MAIL
            EXCEPTIONS
                 PERS_NO_USERID = 1
                 OTHERS         = 2.
    ENDIF.
    END-OF-SELECTION.
    *        FORM CREATE_BDC_SESSION                                       *
    * This form will create a BDC session.                                 *
    FORM CREATE_BDC_SESSIONS.
      REFRESH BDCDATA.
      CLEAR   BDCDATA.
      OLD_RTYPE = SPACE.
      READ TABLE DATA_IN INDEX 1.
      OLD_RTYPE = DATA_IN-RTYPE.
      CLEAR DATA_IN.
      LOOP AT DATA_IN.
        IF OLD_RTYPE EQ '2' AND DATA_IN-RTYPE EQ '1'.
          PERFORM BDC_FIELD USING 'BDC_OKCODE'   '/11'.
          CALL TRANSACTION 'VA01' USING BDCDATA MODE V_VIEW UPDATE 'S'
                                                MESSAGES INTO MESSTAB.
    *  if sy-subrc ne 0.
          PERFORM F_MESSAGE_ANALYSIS.
    *  endif.
          REFRESH BDCDATA.
        ENDIF.
        IF DATA_IN-RTYPE = 1.
          PERFORM TRANS_VA01_HEADER.
        ELSE.
          PERFORM TRANS_VA01_ITEM.
        ENDIF.
        OLD_RTYPE = DATA_IN-RTYPE.
        MOVE-CORRESPONDING DATA_IN TO I_OUTPUT.
        APPEND I_OUTPUT.
        CLEAR I_OUTPUT.
      ENDLOOP.
      PERFORM BDC_FIELD USING 'BDC_OKCODE'   '/11'.
    * Call transaction
      CALL TRANSACTION 'VA01' USING BDCDATA MODE V_VIEW UPDATE 'S'
                                             MESSAGES INTO MESSTAB.
    *  if sy-subrc ne 0.
      PERFORM F_MESSAGE_ANALYSIS.
    *  endif.
      REFRESH BDCDATA.
    ENDFORM.
    *   FORM RANS_va01_header.                                            *
    *   Set up BDCDATA table for transaction VA01.                        *
    FORM TRANS_VA01_HEADER.
    * Process program SAPMV45a screen 0101
    * CREATE sales order Initial screen
      PERFORM BDC_NEW_DYNPRO USING 'SAPMV45A' '0101'.
      PERFORM BDC_FIELD USING 'VBAK-AUART'  DATA_IN-AUART.
      PERFORM BDC_FIELD USING 'VBAK-VKORG'  DATA_IN-VKORG.
      PERFORM BDC_FIELD USING 'VBAK-VTWEG'  DATA_IN-VTWEG.
      PERFORM BDC_FIELD USING 'VBAK-SPART'  DATA_IN-SPART.
    * perform bdc_field using 'VBAK-VKBUR'  data_in-vkbur.
    * perform bdc_field using 'VBAK-VKGRP'  data_in-vkgrp.
      PERFORM BDC_FIELD USING 'BDC_OKCODE'  '/0'.
    * Process program SAPMV45a screen 0402
      PERFORM BDC_NEW_DYNPRO USING 'SAPMV45A' '0402'.
    * Overview screen
      PERFORM BDC_FIELD USING 'KUAGV-KUNNR'  DATA_IN-KUNNR.
      PERFORM BDC_FIELD USING 'VBAK-BSTNK'  DATA_IN-BSTNK.
      PERFORM BDC_FIELD USING 'VBAK-BSTDK'  DATA_IN-BSTDK.
      PERFORM BDC_FIELD USING 'RV45A-KPRGBZ'  DATA_IN-KPRGBZ.
      PERFORM BDC_FIELD USING 'RV45A-KETDAT'  DATA_IN-KETDAT.
    * perform bdc_field using 'VBKD-PRSDT'  data_in-prsdt.
      PERFORM BDC_FIELD USING 'BDC_OKCODE'  'KKAU'.
    * Header Bus data
      PERFORM BDC_NEW_DYNPRO USING 'SAPMV45A' '0300'.
      PERFORM BDC_FIELD USING 'VBAK-LIFSK'  DATA_IN-LIFSK.
      PERFORM BDC_FIELD USING 'VBKD-INCO1'  DATA_IN-INCO1.
      PERFORM BDC_FIELD USING 'VBKD-INCO2'  DATA_IN-INCO1.
      PERFORM BDC_FIELD USING 'VBAK-FAKSK'  DATA_IN-FAKSK.
      PERFORM BDC_FIELD USING 'BDC_OKCODE'  'KPAR'.
    * Partner
      PERFORM BDC_NEW_DYNPRO USING 'SAPDV02P' '0624'.
      PERFORM BDC_FIELD USING 'RV02P-KUNDE(4)'  DATA_IN-KUNDE.
    * text
      IF DATA_IN-LTEXT1 NE SPACE.
        PERFORM CREATE_TEXT.
      ENDIF.
      PERFORM BDC_FIELD USING 'BDC_OKCODE'  'KBES'.
    * Purchase order data
      PERFORM BDC_NEW_DYNPRO USING 'SAPMV45A' '0351'.
      PERFORM BDC_FIELD USING 'VBAK-BSARK'  DATA_IN-BSARK.
      PERFORM BDC_FIELD USING 'VBAK-BNAME'  DATA_IN-BNAME.
      PERFORM BDC_FIELD USING 'VBAK-IHREZ'  DATA_IN-IHREZ.
      PERFORM BDC_FIELD USING 'BDC_OKCODE'  'UER1'.
    ENDFORM.
    *       FORM TRANS_VA01_ITEM                                          *
    FORM TRANS_VA01_ITEM.
      PERFORM BDC_NEW_DYNPRO USING 'SAPMV45A' '0402'.
      IF OLD_RTYPE = '1'.                  "ie, this is the first item.
        PERFORM BDC_FIELD USING 'VBAP-MATNR(001)' DATA_IN-MATNR.
        PERFORM BDC_FIELD USING 'RV45A-KWMENG(001)' DATA_IN-MENGE.
        PERFORM BDC_FIELD USING 'BDC_OKCODE' '/0'.
        PERFORM BDC_NEW_DYNPRO USING 'SAPMV45A' '0402'.
        PERFORM BDC_FIELD USING 'RV45A-VBAP_SELKZ(001)' 'X'.
        PERFORM BDC_FIELD USING 'BDC_OKCODE' 'PKAU'.
        PERFORM TRANS_VA01_ITEM_DETAILS.
      ELSE.
        PERFORM BDC_FIELD USING 'BDC_OKCODE' 'POAN'.       "create item
        PERFORM BDC_NEW_DYNPRO USING 'SAPMV45A' '0402'.
        PERFORM BDC_FIELD USING 'VBAP-MATNR(002)' DATA_IN-MATNR.
        IF DATA_IN-MENGE = SPACE.
          PERFORM BDC_FIELD USING 'RV45A-KWMENG(002)' DATA_IN-FREE_MENGE.
        ELSE.
          PERFORM BDC_FIELD USING 'RV45A-KWMENG(002)' DATA_IN-MENGE.
        ENDIF.
        PERFORM BDC_FIELD USING 'BDC_OKCODE' '/0'.
        PERFORM BDC_NEW_DYNPRO USING 'SAPMV45A' '0402'.
        PERFORM BDC_FIELD USING 'RV45A-VBAP_SELKZ(002)' 'X'.
        PERFORM BDC_FIELD USING 'BDC_OKCODE' 'PKAU'.
        PERFORM TRANS_VA01_ITEM_DETAILS.
      ENDIF.
    ENDFORM.
    *&      Form  TRANS_VA01_ITEM_DETAILS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM TRANS_VA01_ITEM_DETAILS.
    *Business Data
      PERFORM BDC_NEW_DYNPRO USING 'SAPMV45A' '0450'.
      PERFORM BDC_FIELD USING 'VBAP-WERKS' DATA_IN-WERKS.
      IF DATA_IN-MENGE = SPACE.
        PERFORM BDC_FIELD USING 'VBAP-PSTYV' 'TANN'.
      ENDIF.
    *  perform bdc_field using 'VBAP-PSTYV' 'TAN'.
    * route mapping
      IF DATA_IN-ROUTE = 'D'.
        PERFORM BDC_FIELD USING 'VBAP-ROUTE' '000001'.
      ELSE.
      ENDIF.
      PERFORM BDC_FIELD USING 'VBAP-FAKSK' DATA_IN-FAKSK.
      PERFORM BDC_FIELD USING 'BDC_OKCODE'  'UER1'.
    ENDFORM.                               " TRANS_VA01_ITEM_DETAILS
    *       FORM BDC_NEW_DYNPRO                                           *
    *       Updates the BDCDATA table with the program and screen number  *
    *       of the next screen.                                           *
    FORM BDC_NEW_DYNPRO USING PROGRAM DYNPRO.
      CLEAR BDCDATA.
      BDCDATA-PROGRAM = PROGRAM.
      BDCDATA-DYNPRO  = DYNPRO.
      BDCDATA-DYNBEGIN = 'X'.
      APPEND BDCDATA.
    ENDFORM.
    *       FORM BDC_FIELD                                                *
    *       Updates the BDCDATA table with the field name and value of    *
    *       the current screen.                                           *
    *  -->  FIELD  -  Field name                                          *
    *  -->  VALUE  -  Field value                                         *
    FORM BDC_FIELD USING FIELD VALUE.
      IF VALUE NE SPACE.
        CLEAR BDCDATA.
        BDCDATA-FNAM = FIELD.
        BDCDATA-FVAL = VALUE.
        APPEND BDCDATA.
      ENDIF.
    ENDFORM.
    *&      Form  READ_FILE
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM READ_FILES.
    * Read order headers
      OPEN DATASET IDLH FOR INPUT IN TEXT MODE.
      IF SY-SUBRC NE 0.
        MESSAGE E002(ZZ) WITH 'Cannot find file in directory'.
      ENDIF.
      DO.
        READ DATASET IDLH INTO IDLORDH.
        IF SY-SUBRC NE 0.
          EXIT.
        ENDIF.
        APPEND IDLORDH.
      ENDDO.
      CLOSE DATASET IDLH.
    * Read order items
      OPEN DATASET IDLI FOR INPUT IN TEXT MODE.
      IF SY-SUBRC NE 0.
        MESSAGE E002(ZZ) WITH 'Cannot find file in directory'.
      ENDIF.
      DO.
        READ DATASET IDLI INTO IDLORDI.
        IF SY-SUBRC NE 0.
          EXIT.
        ENDIF.
        APPEND IDLORDI.
      ENDDO.
      CLOSE DATASET IDLI.
    ENDFORM.                               " READ_FILE_INTO_CUST
    *&      Form  DEL_INP_FILE
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM DEL_INP_FILE.
      DATA: PARAX(128).
      DATA: PARAM(200).
      DATA: CMDSTR(18),
            CMD_RESULT  LIKE BTCXPM OCCURS 10 WITH HEADER LINE,
            LINES TYPE I.
      DATA: PATH1(60) TYPE C.
      DATA: PATH2(60) TYPE C.
      DATA: NAME(20) TYPE C.
      DATA: INTNAME(20) TYPE C VALUE 'LAPTOP',
            V_FILENAME1(20) TYPE C VALUE 'ORDHT',
            V_FILENAME2(20) TYPE C VALUE 'ORDIT'.
      DATA: V_DATE LIKE SY-DATUM.
      V_DATE = SY-DATUM+4(4).
      CLEAR PARAX.
    * build IN directory
      PATH1 ='/'.
      WRITE SY-SYSID TO PATH1+1(3).        "D01 or T01 or P01 !
      WRITE 'INT/'    TO PATH1+4(4).       "Interfaces
      WRITE INTNAME TO PATH1+8(20).
      CONDENSE PATH1 NO-GAPS.
      WRITE '/IN' TO PATH1+30(5).
      CONDENSE PATH1 NO-GAPS.
    * build ARCH directory
      PATH2 ='/'.
      WRITE SY-SYSID TO PATH2+1(3).        "D01 or T01 or P01 !
      WRITE 'INT/'    TO PATH2+4(4).       "Interfaces
      WRITE INTNAME TO PATH2+8(20).
      CONDENSE PATH2 NO-GAPS.
      WRITE '/ARCH' TO PATH2+30(5).
      CONDENSE PATH2 NO-GAPS.
      DO 2 TIMES.
        CASE SY-INDEX.
          WHEN 1.
            IF IDLEX = 'X'.
              CONCATENATE 'IDL' V_FILENAME1 INTO NAME.
            ELSE.
              CONCATENATE 'DB' V_FILENAME1 INTO NAME.
            ENDIF.
    *   name = filename1.
          WHEN 2.
            IF IDLEX = 'X'.
              CONCATENATE 'IDL' V_FILENAME2 INTO NAME.
            ELSE.
              CONCATENATE 'DB'  V_FILENAME2 INTO NAME.
            ENDIF.
    *    name = filename2.
        ENDCASE.
        CMDSTR = 'ZMOV'.
        WRITE ' OBJ( TO PARAM.
        WRITE PATH1 TO PARAM+7(50).
        WRITE '/'   TO PARAM+50(1).
        CONDENSE PARAM NO-GAPS.
        WRITE NAME TO PARAM+70(12).
        CONDENSE PARAM NO-GAPS.
        WRITE )@TOOBJ( TO PARAM+70(13).
        CONDENSE PARAM NO-GAPS.
        WRITE PATH2 TO PARAM+82(60).
        CONDENSE PARAM NO-GAPS.
        WRITE '/'   TO PARAM+140(1).
        CONDENSE PARAM NO-GAPS.
        WRITE V_DATE TO PARAM+140(4).
        CONDENSE PARAM NO-GAPS.
        WRITE NAME TO PARAM+140(15).
        CONDENSE PARAM NO-GAPS.
        WRITE )' TO PARAM+142(5).
        CONDENSE PARAM NO-GAPS.
        REPLACE '@' WITH ' ' INTO PARAM.
    *  replace '@' with ' ' into param.
        MOVE PARAM(127) TO PARAX(127).
        CALL FUNCTION 'SXPG_CALL_SYSTEM'
             EXPORTING
                  COMMANDNAME       = CMDSTR
                  PARAMETERS        = PARAX
             TABLES
                  EXEC_PROTOCOL     = CMD_RESULT
             EXCEPTIONS
                  NO_PERMISSION     = 1
                  COMMAND_NOT_FOUND = 2
                  OTHERS            = 4.
        IF SY-SUBRC <> 0.                  "extenal command not executed
        MESSAGE I002 WITH 'error calling external command - call sys admin'.
        ENDIF.
      ENDDO.
    ENDFORM.                               " DEL_INP_FILE
    *&      Form  CREATE_TEXT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM CREATE_TEXT.
      PERFORM BDC_FIELD USING 'BDC_OKCODE'  'KTEX'.
    * Text overview
      PERFORM BDC_NEW_DYNPRO USING 'SAPMV45A' '0150'.
      PERFORM BDC_FIELD USING 'RTEXT-SELKZ(02)' 'X'.
      PERFORM BDC_FIELD USING 'RTEXT-SPRAS(02)' 'E'.
      PERFORM BDC_FIELD USING 'BDC_OKCODE'  'TEDE'.
    * Text editor
      PERFORM BDC_NEW_DYNPRO USING 'SAPLSTXX' '1100'.
      PERFORM BDC_FIELD USING 'BDC_OKCODE'  '/06'.
      PERFORM BDC_NEW_DYNPRO USING 'SAPLSTXX' '1100'.
      PERFORM BDC_FIELD USING 'BDC_CURSOR' 'RSTXT-TXLINE(02)'.
      PERFORM BDC_FIELD USING 'RSTXT-TXLINE(02)' DATA_IN-LTEXT2(70).
      PERFORM BDC_FIELD USING 'BDC_OKCODE'  '/06'.
      PERFORM BDC_NEW_DYNPRO USING 'SAPLSTXX' '1100'.
      PERFORM BDC_FIELD USING 'BDC_CURSOR' 'RSTXT-TXLINE(02)'.
      PERFORM BDC_FIELD USING 'RSTXT-TXLINE(02)' DATA_IN-LTEXT1(70).
      PERFORM BDC_FIELD USING 'BDC_CURSOR' 'RSTXT-TXLINE(04)'.
    * perform bdc_field using 'BDC_OKCODE'  '/06'.
    * perform bdc_new_dynpro using 'SAPLSTXX' '1100'.
    *  PERFORM BDC_FIELD USING 'RSTXT-TXLINE(004)' DATA_IN-ltext+140(70).
    *  PERFORM BDC_FIELD USING 'BDC_OKCODE'  '/06'.
    *  PERFORM BDC_NEW_DYNPRO USING 'SAPLSTXX' '1100'.
    *  PERFORM BDC_FIELD USING 'RSTXT-TXLINE(005)' DATA_IN-ltext+210(46).
    *  PERFORM BDC_FIELD USING 'BDC_OKCODE'  '/06'.
      PERFORM BDC_NEW_DYNPRO USING 'SAPLSTXX' '1100'.
      PERFORM BDC_FIELD USING 'BDC_OKCODE'  'TXVB'.
      PERFORM BDC_NEW_DYNPRO USING 'SAPLSTXX' '1100'.
      PERFORM BDC_FIELD USING 'BDC_OKCODE'  'TXEX'.
      PERFORM BDC_NEW_DYNPRO USING 'SAPMV45A' '0150'.
    ENDFORM.                               " CREATE_TEXT
    *&      Form  MAP_DATA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM MAP_DATA.
      TABLES: KNB1, CABN, AUSP.
      TABLES: ZPM1.
      DATA: V_CUST_NO(11) TYPE C.
      CLEAR IDLORDH.
      CLEAR DATA_IN.
      SELECT * FROM CABN
            WHERE ATNAM = 'ORDER_ENTRY_CODE'.
        EXIT.
      ENDSELECT.
      SELECT OBJEK ATWRT INTO (I_MATERIAL-MATNR, I_MATERIAL-ORDER)
            FROM AUSP
            WHERE ATINN = CABN-ATINN.
      APPEND I_MATERIAL.
    ENDSELECT.
    LOOP AT IDLORDH.
      MOVE '1' TO DATA_IN-RTYPE.
    * Order type.
      DATA_IN-AUART = 'ZOR'.
    * Sales organisation
      IF IDLEX EQ 'X'.
        DATA_IN-VKORG = '1100'.            "idl domestic.
      ELSE.
        DATA_IN-VKORG = '1350'.            "dillion bass domestic.
      ENDIF.
    * Distribution Channel
      DATA_IN-VTWEG = '10'.
    * Division
      DATA_IN-SPART = '10'.
    * Customer Number
      IF IDLORDH-CUST-NO(1) = SPACE.
        CONCATENATE '0' IDLORDH-CUST-NO INTO V_CUST_NO.
        CONDENSE V_CUST_NO NO-GAPS.
      ELSE.
        V_CUST_NO = IDLORDH-CUST-NO.
      ENDIF.
      DO 4 TIMES.
        IF IDLORDH-BRANCH-NO CS SPACE.
          REPLACE SPACE WITH '0' INTO IDLORDH-BRANCH-NO.
        ENDIF.
      ENDDO.
      move idlordh-branch-no to v_cust_no+7(4).
      select * from knb1 where eikto = v_cust_no.
        EXIT.
      ENDSELECT.
      MOVE KNB1-KUNNR TO DATA_IN-KUNNR.
    * Sales Office
    *ata_in-vkbur.
    * Sales Group
    *ata_in-vkgrp
    * PO number
      DATA_IN-BSTNK = IDLORDH-CUST-ORDER-NO.
    * PO ref number
      IF IDLORDH-IDL-ORDER-NO(1) EQ SPACE.
        MOVE IDLORDH-IDL-ORDER-NO TO V_IDL-ORDER-NO.
        REPLACE SPACE WITH '0' INTO V_IDL-ORDER-NO.
      ENDIF.
      MOVE IDLORDH-PC-USER-NO TO V_PC-USER-NO.
      DO 3 TIMES.
        REPLACE SPACE WITH '0' INTO V_PC-USER-NO.
      ENDDO.
      CONCATENATE V_IDL-ORDER-NO '-' V_PC-USER-NO INTO V_IHREZ.
      DATA_IN-IHREZ = V_IHREZ.
    * PO Date
      DATA_IN-BSTDK = IDLORDH-PC-ORDER-DATE.
      DO 2 TIMES.
        REPLACE '/' WITH '.' INTO IDLORDH-PC-ORDER-DATE.
      ENDDO.
      DATA_IN-BSTDK = IDLORDH-PC-ORDER-DATE.
    * Date Type
    *ata_in-kprgbz
    * Required Delivery Date
      DO 2 TIMES.
        REPLACE '/' WITH '.' INTO IDLORDH-PC-DATE-REQD.
      ENDDO.
      DATA_IN-KETDAT = IDLORDH-PC-DATE-REQD.
    *pricing date
    *ata_in-prsdt
    *delivery block
    *ata_in-lifsk
    *inco terms.
      IF IDLORDH-FOR-COLLECTION = 'Y'.
        DATA_IN-INCO1 = 'EXW'.
      ELSE.
        DATA_IN-INCO1 = 'CIF'.
      ENDIF.
    *inco description
    *ata_in-inco2
    *billing block
      IF IDLORDH-HOLD-FOR-PRICING = 'Y'.
        DATA_IN-FAKSK = '99'.
      ENDIF.
    *shipto
    *ata_in-kunde
    *special text
      DATA_IN-LTEXT1 = IDLORDH-SPEC-INS-1.
      DATA_IN-LTEXT2 = IDLORDH-SPEC-INS-2.
    *ordering method
      DATA_IN-BSARK = 'LAPT'.
    *plant.
      SELECT * FROM ZPM1
         WHERE ZLPLANT = IDLORDH-SITE-PREFIX.
        EXIT.
      ENDSELECT.
      DATA_IN-WERKS = ZPM1-ZWERKS.
    *orderer
    *data_in-bname
      APPEND DATA_IN.
      CLEAR DATA_IN.
      LOOP AT IDLORDI WHERE IDL-ORDER-NO = IDLORDH-IDL-ORDER-NO AND
                            PC-USER-NO = IDLORDH-PC-USER-NO.
        MOVE '2' TO DATA_IN-RTYPE.
    *item
    *material no.
        READ TABLE I_MATERIAL WITH KEY ORDER = IDLORDI-ORDER-ENTRY-CODE.
        DATA_IN-MATNR = I_MATERIAL-MATNR.
    *Order quantity
        DATA_IN-MENGE = IDLORDI-QTY-TO-ORDER.
        DATA_IN-FREE_MENGE = IDLORDI-FREE-QTY-ORDERED.
    *plant.
        DATA_IN-WERKS = ZPM1-ZWERKS.
    *ata_in-pstyv
    *       route
    *       vrkme
    *       itext
        APPEND DATA_IN.
        IF  IDLORDI-FREE-QTY-ORDERED > 0.
          CLEAR DATA_IN-MENGE.
          APPEND DATA_IN.
        ENDIF.
        CLEAR DATA_IN.
      ENDLOOP.
    ENDLOOP.
    ENDFORM.                               " MAP_DATA
    *&      Form  F_MESSAGE_ANALYSIS
    *  <--  p2        text
    FORM F_MESSAGE_ANALYSIS.
      DATA: V_FIRST(1) TYPE C VALUE '1',
            V_COUNT(2) TYPE N,
            V_MESSAGE(1) TYPE C,
            V_MESSLINES(2) TYPE N.
      CLEAR: V_IHREZ, V_MESSLINES.
      DESCRIBE TABLE MESSTAB LINES V_MESSLINES.
      READ TABLE MESSTAB WITH KEY MSGTYP = 'S' MSGID = 'V1' MSGNR = '311'.
      IF SY-SUBRC = 0.
        IF V_MESSLINES = 1.
          V_MESSAGE = 'S'.
        ELSE.
          V_MESSAGE = 'W'.
          V_MAIL = 1.
        ENDIF.
        V_VBELN = MESSTAB-MSGV2(08).
      ELSE.
        V_MESSAGE = 'E'.
        V_MAIL = 1.
      ENDIF.
      V_FIRST = 1.
      LOOP AT I_OUTPUT.
        IF V_FIRST = 1.
          MOVE I_OUTPUT-IHREZ TO V_IHREZ.
          CLEAR V_FIRST.
        ENDIF.
        ZSOM1-VBELN = V_VBELN.
        ZSOM1-ITEM_NO = V_ITEM_NO.
        ZSOM1-MESS = V_MESSAGE.
        MOVE-CORRESPONDING I_OUTPUT TO ZSOM1.
        ZSOM1-IHREZ = V_IHREZ.
        MODIFY ZSOM1.
        CLEAR ZSOM1.
        V_ITEM_NO = V_ITEM_NO + 1.
      ENDLOOP.
      LOOP AT MESSTAB.
        V_COUNT = V_COUNT + 1.
        ZSOM2-MCOUNT = V_COUNT.
        ZSOM2-IHREZ = V_IHREZ.
        CASE MESSTAB-MSGTYP.
          WHEN 'E'.
            MOVE-CORRESPONDING MESSTAB TO ZSOM2.
          WHEN 'A'.
            MOVE-CORRESPONDING MESSTAB TO ZSOM2.
          WHEN 'W'.
            MOVE V_VBELN TO ZSOM2-VBELN.
            MOVE-CORRESPONDING MESSTAB TO ZSOM2.
          WHEN 'I'.
            MOVE V_VBELN TO ZSOM2-VBELN.
            MOVE-CORRESPONDING MESSTAB TO ZSOM2.
          WHEN 'S'.
            MOVE V_VBELN TO ZSOM2-VBELN.
            MOVE-CORRESPONDING MESSTAB TO ZSOM2.
        ENDCASE.
        MODIFY ZSOM2.
        CLEAR ZSOM2.
      ENDLOOP.
      REFRESH: MESSTAB, I_OUTPUT.
      CLEAR: MESSTAB, I_OUTPUT.
      CLEAR: V_FIRST, V_VBELN, V_IHREZ, V_ITEM_NO, V_COUNT, V_MESSAGE.
    ENDFORM.                               " F_MESSAGE_ANALYSIS
    *&      Form  F_TABLE_LOAD
    FORM F_TABLE_LOAD.
      SELECT * FROM ZSOM1
       WHERE IHREZ IN O_IHREZ
         AND MESS = 'E'.
        IF NOT ZSOM1-VBELN IS INITIAL.
          CHECK ZSOM1-VBELN IN O_VBELN.
        ENDIF.
        MOVE-CORRESPONDING ZSOM1 TO DATA_IN.
        APPEND DATA_IN.
        CLEAR DATA_IN.
      ENDSELECT.
    ENDFORM.                               " F_TABLE_LOAD

  • Data Transfer from Flat file To SAP system,

    Hi SAP Guru's,
    My query is :
    How to update Material master data by using idoc type MATMAS05 . The data is present in flat file at application server.
    I am  new to idoc area.Please provide me the sample program that how to update material master data by using standard idoc type.
    I am clear with the point that we have to read flat file from application server to internal table.
    But i got stucked at this point that how to update data from internal table data , by using standard idoc type MATMAS 05.
    I am in real need.Please provide me with the answer of this query.
    I will really appreciate your <<removed by moderator>> reply.
    Thanks
    Simran
    Edited by: Simran_SAP on Aug 25, 2010 10:46 AM
    Edited by: kishan P on Aug 25, 2010 4:36 PM

    Hi Vinod,
    Thanks for reply..
    I am new to idoc area.and my requirement is to generate the idoc after reading data from a flat file. The file is passed to the application server
    by a middleware . The SAP interface program reads the file from the application server and then starts processing the data. Please help me how to create the inbound IDoc and which FM needs to be used.
    Please provide a sample Program .
    This will really help..
    Waiting fr ur early response.
    Thanks
    Simran

Maybe you are looking for

  • I would like to know which model has been discontinued? is it EOS 600D or 650D?

    i would like to know which model has been discontinued? is it EOS 600D or 650D?  And is 650d at 1650 a good deal? 

  • ORA-01722: invalid number performing List of Values query

    I have a situation here where I want to pass string value(available in search field) to POP up key LOV on another page as default value. I passed item value in default field in POPup key LOV item.I am able to see string value but It also gave me foll

  • IPod Touch 4G 'USB Device Malfunctioned'

    My iPod touch 4th Generation charges when connected to aan external dock, but will not connect to my brand new Laptop, my wall connector, or any other device I have tried it on. The cable is okay because it charges my iPhone (which connects to the la

  • Fetching the 4th row directly

    i have a question how to fetch the 4th row directly instead of starting from the frist row. see my table is having 30 records i have written a cursor that will fetches 10 rows based on the condition . k . now i want the 4 th row direclty. i tried wit

  • How do I keep my Ipad from dropping its wireless connection?

    How do I keep my Ipad from dropping its wireless connection? Most of the time, my iPad does not maintain a connection to the interenet via my wifi router. My PC laptop has continuous connection, so I know it is not the internet connection. Is there a