How to check syntax errors in ABAP Queries

HI Guys,
How to check syntax errors in ABAP queries, Can please provide the T-Codes.
Advande thanks to everybody.
Thanks,
Gourisankar

Hi
with these you can check syntax errors and performance points
Hi
these all are doing t he same thing that is checking the program for better performance
Tools for Performance Analysis
Run time analysis transaction SE30
SQL Trace transaction ST05
Extended Program Check (SLIN)
Code Inspector ( SCI)
Run time analysis transaction SE30 :This transaction gives all the analysis of an ABAP program with respect to the database and the non-database processing.
SQL Trace transaction ST05: The trace list has many lines that are not related to the SELECT statement in the ABAP program. This is because the execution of any ABAP program requires additional administrative SQL calls. To restrict the list output, use the filter introducing the trace list.
The trace list contains different SQL statements simultaneously related to the one SELECT statement in the ABAP program. This is because the R/3 Database Interface - a sophisticated component of the R/3 Application Server - maps every Open SQL statement to one or a series of physical database calls and brings it to execution. This mapping, crucial to R/3s performance, depends on the particular call and database system. For example, the SELECT-ENDSELECT loop on a particular database table of the ABAP program would be mapped to a sequence PREPARE-OPEN-FETCH of physical calls in an Oracle environment.
The WHERE clause in the trace list's SQL statement is different from the WHERE clause in the ABAP statement. This is because in an R/3 system, a client is a self-contained unit with separate master records and its own set of table data (in commercial, organizational, and technical terms). With ABAP, every Open SQL statement automatically executes within the correct client environment. For this reason, a condition with the actual client code is added to every WHERE clause if a client field is a component of the searched table.
To see a statement's execution plan, just position the cursor on the PREPARE statement and choose Explain SQL. A detailed explanation of the execution plan depends on the database system in use.
Extended Program Check
This can be called in through transaction SE38 or through transaction SLIN. This indicates possible problems that may cause performance problems.
Code Inspector (SCI)
You can call the Code Inspector from the ABAP Editor (SE38), the Function Builder (SE37), the Class Builder (SE24), or as a separate transaction (SCI).
The Code Inspector indicates possible problems. However, note that, especially with performance issues: There is no rule without exception. If a program passes an inspection, it does not necessarily mean that this program will have no performance problems.
reward if usefull

Similar Messages

  • How to check particular error in alert log file

    Hi all,
    How to check particular error in alert log file,for supose if i get error in batabase yesterday 4 pm & today i want to check alert log file to get basic idea..it might be a big file so how to check that particular error..
    Thanks & regards,
    Eswar..

    What's your oracle version?
    If you are in 11g you can use adrci tool
    1- set homes diag/rdbms/orawiss/ORAWISS/ : the rdbms home
    2- show alert -P "MESSAGE_TEXT LIKE '%ORA-%'" -term : to find all the ORA-% errors in the alert file
    3- show alert -P "MESSAGE_TEXT LIKE '%ORA-%' and originating_timestamp > systimestamp-51 " -term : to find all the ORA-% errors in the alert file during the last 51 days,
    4- show alert -P "MESSAGE_TEXT LIKE '%ORA-%' and originating_timestamp > systimestamp-1/24 " -term : to find all the ORA-% errors in the alert file during the last hour,
    5- show alert -P "MESSAGE_TEXT LIKE '%ORA-12012%' and originating_timestamp > systimestamp-1/24 " -term : to find the particular ORA-12012 error in the alert file during the last hour,
    Example:
    [oracle@wissem wissem]$ adrci
    ADRCI: Release 11.2.0.1.0 - Production on Wed May 4 10:24:54 2011
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    ADR base = "/home/oracle/app/oracle"
    adrci> set homes diag/rdbms/orawiss/ORAWISS/
    adrci> show alert -P "MESSAGE_TEXT LIKE '%ORA-'" -term
    ADR Home = /home/oracle/app/oracle/diag/rdbms/orawiss/ORAWISS:
    adrci> show alert -P "MESSAGE_TEXT LIKE '%ORA-%'" -term
    ADR Home = /home/oracle/app/oracle/diag/rdbms/orawiss/ORAWISS:
    2010-12-11 19:45:41.289000 +01:00
    ORA-1109 signalled during: ALTER DATABASE CLOSE NORMAL...
    ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
    ORA-01152: file 1 was not restored from a sufficiently old backup
    ORA-01110: data file 1: '/home/oracle/app/oracle/oradata/ORAWISS/system01.dbf'
    ORA-1547 signalled during: ALTER DATABASE RECOVER  database until time '2011-01-21:10:48:00'  ...
    Errors in file /home/oracle/app/oracle/diag/rdbms/orawiss/ORAWISS/trace/ORAWISS_j000_5692.trc:
    ORA-12012: error on auto execute of job 29
    ORA-01435: user does not exist
    2011-03-15 11:39:37.571000 +01:00
    opiodr aborting process unknown ospid (31042) as a result of ORA-609
    2011-03-15 12:04:15.111000 +01:00
    opiodr aborting process unknown ospid (3509) as a result of ORA-609
    adrci>
    adrci> show alert -P "MESSAGE_TEXT LIKE '%ORA-%' and originating_timestamp > systimestamp-51 " -term
    ADR Home = /home/oracle/app/oracle/diag/rdbms/orawiss/ORAWISS:
    2011-03-15 10:19:45.316000 +01:00
    Errors in file /home/oracle/app/oracle/diag/rdbms/orawiss/ORAWISS/trace/ORAWISS_j006_5536.trc:
    ORA-12012: error on auto execute of job 26
    ORA-01435: user does not exist
    Errors in file /home/oracle/app/oracle/diag/rdbms/orawiss/ORAWISS/trace/ORAWISS_j000_5692.trc:
    ORA-12012: error on auto execute of job 29
    ORA-01435: user does not exist
    2011-03-15 11:39:37.571000 +01:00
    opiodr aborting process unknown ospid (31042) as a result of ORA-609
    2011-03-15 12:04:15.111000 +01:00
    opiodr aborting process unknown ospid (3509) as a result of ORA-609
    adrci>

  • Errors in ABAP queries

    Hi Experts,
    Iam working in upgradation project( from 3.1i to ECC 6.0) there are some ABAP queries which are moved from 3.1i to ECC 6.0 the infoset contains the errors so iam unable to move it to quality server because of erros i have tried with ADJUST option but the result is same please any body suggest me how to tranport to quality it's very urgent.
    Thank you

    Hi,
    check wheather u have make Unicode Active in all Generated Programs.
    Regards,
    Balakumar.G
    Reward Points if helpful.

  • Syntax error in ABAP Query

    Hi All,
    We are facing syntax erro with ABAP query.
    We have a infoset/query which is perfectly working in one system and we downloaded the both infoset and query from this system.But the same query when it is uploaded to other system is not working.
    Infoset is not giving any syntax error while activation. Morever, the generated report struture is also different from the other system. In old system, report was having one include for declaration and other for data retrieval process etc.
    Can you please help us to resolve this issue?
    Thanks

    Hi,
    The query generated is based on the table structures available as they are used, etc.
    So please check if there is any difference in the fields available in the tables used, LDB used if any.
    In addition, may be few of the properties of the SAP query and info set does not get copied properly.
    and after activating the info set only, activate the query, etc...check them once again.
    Regards,
    Santhosh.

  • How to find syntax errors in TestStand?

    Hi,
    I have about 70 sequences and I'm trying to find any syntax errors, which evaded my "error radar". How can I find these in TestStand without moving through every step (which would around 1000 and more steps!)? I'm missing something like the "syntax" check in LabVIEW, which indicates right in your face, if you brake the block diagram.
    Thanks for any help.
    Marc
    CLD
    Solved!
    Go to Solution.

    Checking expressions at edit time to make sure that they will evaluate correctly at run time is a tricky process.  For instance, what if you are dynamically creating an array at run time, and then iterating through that array.  Unless you give that array good default values (which may be difficult if it is an array of custom types), your expressions will not be correct at edit time, and could be flagged as errors.
    However, this is a request that we have heard quite a bit, and NI is investigating ways to allow customers to validate their expressions before running a sequence.
    In the meantime, one of the TestStand developers created a tool that does what Doug was describing: iterates through every property object in a file and if it is an expression, tries to evaluate it.  This tool is written as a sequence file in TestStand 4.1.  Please note that since it uses recursion to iterate through each property object, and since recursion with sequences can be rather slow, the performance of this tool may be improved by duplicating its functionality with a code module (rather than sequence steps).
    Message Edited by Josh W. on 03-30-2009 02:20 PM
    Josh W.
    Certified TestStand Architect
    Formerly blue
    Attachments:
    CheckExpressions41.seq ‏13 KB

  • Syntax error in ABAP query after implement patch

    Dear All,
    After implement patch from SAPKA46C39 to SAPKA46C53, we have syntax error in our query.
    our SAP release version is 46C.
    The error in query is -The data object "R01" does not have a component called "046" -
    We don't found any SAP notes that match for our error.
    Anyone ..please help...
    Thanks a lot...
    Budituta

    Hi,
    The query generated is based on the table structures available as they are used, etc.
    So please check if there is any difference in the fields available in the tables used, LDB used if any.
    In addition, may be few of the properties of the SAP query and info set does not get copied properly.
    and after activating the info set only, activate the query, etc...check them once again.
    Regards,
    Santhosh.

  • How to get syntax errors in english rather than german

    How to see the errors in english instead of german on the same page...any navigations for that....
    thanks

    Hi Balaji,
    After you copy a Std SAP Program into ZPROGRAM,
    In ABAP Editor see Goto -> Attributes.
    System will throw a pop-up window, In which press change original language.
    then you can be able to change to English.
    Regards
    Venkat.
    Award Points, if helpful.
    Message was edited by:
            venkat Kumbham

  • How to remove syntax error for the method which i deleted?

    Hi,
    I implemented a attribute NAME2 in BP_ADDR/AddressDuplicate , in that i implemented GET_P_NAME2 and later deleted attribute it self now i am getting the error "ZL_BP_ADDR_ADDRESSDUPLICA_CN02CP Method "GET_P_NAME2" does not exist. There is, however, a method with the similar name "GET_BP_NAME"
    how to remove this error?
    regards
    Vinay

    Hi Pankaj,
    I tried that it is giving dump
    The following syntax error occurred in program
    "ZL_BP_ADDR_ADDRESSDUPLICA_CN02CP " in include
    "ZL_BP_ADDR_ADDRESSDUPLICA_CN02CM01D " in
    line 1:
    "Method "GET_P_NAME2" does not exist. There is, however, a method with "
    "the similar name "GET_BP_NAME"."
    any clue how to solve this?
    Vinay

  • Prgm /FM to check syntax errors of list of prgms

    Hi All,
    Is there any program/report/function module or any other means to check and list the syntax errors of a list of programs?
    Thank You.
    Regards,
    Soumya

    Hi,
    Try this statement SYNTAX-CHECK
    Go through this documentation
    [Syntax Check|http://help.sap.com/abapdocu_70/en/ABAPSYNTAX-CHECK_FOR_ITAB.htm]
    Alternatively , you can also try this FM EXTENDED_PROGRAM_CHECK.
    Regards,
    Lakshman.

  • How to fix Syntax Error: Expected end of line, etc. but found end of script. in applescript?

    I am making an applescript for my modding tool for Minecraft. It used to use multiple apps and I am now trying to make one app for all the tasks.
    Here is the code:
    say "You are running iCraft version one point one for minecraft version 1.2.5"
    display dialog "Which tool do you want to use?" buttons {"Mod Installer", "Backup", "Restore"} default button 3
    set the button_pressed to the button returned of the result
    if the button_pressed is "Mod Installer" then
    do shell script "~/desktop/iCraft/iCraft.app/contents/re…
    display dialog "Insert all mod files into the Mods folder."
    display dialog "Have you inserted all Mod files into the Mods folder?" buttons {"Yes", "No"} default button 2
    if the button_pressed is "Yes" then
    do shell script "~/desktop/iCraft/iCraft.app/contents/re…
    display dialog "Finished"
    else
    display dialog "Insert mod files into the Mods folder and restart iCraft.app."
    end if
    if the button_pressed is "Backup" then
    display dialog "Are you sure you want to backup your Minecraft.jar in it's current state?" buttons {"Yes", "No"} default button 2
    if the button_pressed is "Yes" then
    do shell script "~/desktop/iCraft/iCraft.app/contents/re…
    display dialog "Finished, find it in your Backups directory in the iCraft folder"
    else
    display dialog "Backup aborted"
    end if
    if the button_pressed is "Restore" then
    display dialog "Are you sure you want to restore your Minecraft.jar with your backup?" buttons {"Yes", "No"} default button 2
    if the button_pressed is "Yes" then
    do shell script "~/desktop/iCraft/iCraft.app/resources/s…
    else
    display dialog "Restore aborted"
    end if
    end
    When I try to compile/run it gives me Syntax Error: Expected end of line, etc. but found end of script.

    Your script got mangled when pasting it into your message, but the main problem looks like you are missing a bunch of end if statements.  Unless your if statements are contained on one line, you need to terminate them with a matching end if statement - for example, the following are equivalent:
    if someString is "whatever" then display dialog "foo"
    if someString is "whatever" then
      display dialog "foo"
    end if

  • Syntax error in ABAP HR program

    Hello Experts,
    I am new to programming in HR. I am getting a syntax error "PERNR is not defined for the current logical database" with the following piece of code.
    TABLES: PERNR.
    INFOTYPES: 0002, 0006.
    GET PERNR.
    PROVIDE * FROM P0002 BETWEEN PN-BEGDA AND PN-ENDDA.
    WRITE: P0002-PERNR, P0002-NACHN, P0002-VORNA.
    ENDPROVIDE.
    Am I missing a statement or something needs to be configured in the system?
    Any help will be highly appreciated.
    thanks...
    Rony.

    HI,
      your code works perfectly well.. I have added the PNP logical database and selection screen 100... i think you r not added this PNP logical database
    *& Report  ZTESTPRG                                                    *
    REPORT  ZTESTPRG                                .
    TABLES: PERNR.
    INFOTYPES: 0002, 0006.
    GET PERNR.
      PROVIDE * FROM P0002 BETWEEN PN-BEGDA AND PN-ENDDA.
        WRITE: P0002-PERNR, P0002-NACHN, P0002-VORNA.
      ENDPROVIDE.
    Thanks
    mahesh

  • How to check the error log in sharepoint 2013 online (office 365)

    I'm working with sharepoint online instance. I'm developing a sharepoint app using Napa 365 but its giving me some error with the correlation ID. Where i have to check the error log to get the actual error description?
    Please suggest me the right direction.
    Thanks in advance!

    Hi,
    As your environment is SharePoint Online, I suggest you can create a new thread in SharePoint Online forum, you will get more detailed information from there and more experts will help you.
    Office 365 Forum:
    http://community.office365.com/en-us/f/default.aspx
    Thanks for your understanding.
    Best Regards
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • How do we track back the ABAP queries/report painter used to custom report?

    Hi Experts,
    I only have some ideas about report painter and ABAP query. If a company has a number of different Z reports in production.
    1. How do we identify if it's report painter/writer or ABAP query??
    2. For ABAP query report, suppose that i can identify one. If i am given a Z tcode of that report and identify the program of that report behind it, How do i know what query that program belongs to?? What are the steps i go back in SQ03 to view that query??
    3. For report painter, starting from ztcode of the report, where do i check and track the original painter of that report??
    Please help clarify my doubts..
    Monica

    Hi Monica,
    For report painter/writer, you can identified it by go to
    Environment --> Technical information when you execute your Z-tcode.
    To refer back to the report painter/writer t-code you just need to double click oh the report group that you see by clicking the link above.
    Thanks,
    Victor.

  • How to check for errors in starting workflow from plsql?

    Hi All,
    I am using the below code to start a custom workflow.
    DECLARE
    l_itemtype VARCHAR2(30) := 'XXPWA';
    l_itemkey  VARCHAR2(30) := '1116410C';
    error_code VARCHAR2(2000);
    error_msg  VARCHAR2(2000);
    BEGIN
        wf_engine.createprocess(l_itemtype, l_itemkey, 'XX_WEBADI_APPROVAL');
        wf_engine.setitemuserkey(itemtype => l_itemtype
                                ,itemkey  => l_itemkey
                                ,userkey  => 'USERKEY: ' || '1116410C');
        wf_engine.setitemowner(itemtype => l_itemtype
                              ,itemkey  => l_itemkey
                              ,owner    => 'SYSADMIN');
        wf_engine.setitemattrnumber(itemtype => l_itemtype
                                   ,itemkey  => l_itemkey
                                   ,aname    => 'BATCH_ID'
                                   ,avalue   => 1116410);
        wf_engine.startprocess(l_itemtype, l_itemkey);
    EXCEPTION
    WHEN OTHERS THEN
    error_code := SQLCODE;
    error_msg  := SQLERRM(SQLCODE);
    dbms_output.put_line(error_code||error_msg);
    END ;
    The script completes successfully without errors.
    I am sending a notification from this workflow. I can see the records getting created in tables like WF_NOTIFICATIONS and WF_ITEM_ATTRIBUTE_VALUES. But i cannot see any thing if i query from Status Monitor. Also I am not getting the said notifications. How can i find what is the issue?

    Hi Manu,
    Thanks for sharing the information, If you think of speeding up finding were exactly your notification is struck, You can use the below query (Input parameter would be your notification id), Hope this information is good, I liked this very much, the way it was narrated.
    SELECT n.begin_date,
           n.status,
           n.mail_status,
           n.recipient_role,
           de.def_enq_time,
           de.def_deq_time,
           de.def_state,
           ou.out_enq_time,
           ou.out_deq_time,
           ou.out_state
      FROM applsys.wf_notifications n,
           (SELECT d.enq_time def_enq_time,
                   d.deq_time def_deq_time,
                   TO_NUMBER((SELECT VALUE
                               FROM TABLE(d.user_data.parameter_list)
                              WHERE NAME = 'NOTIFICATION_ID')) d_notification_id,
                   msg_state def_state
              FROM applsys.aq$wf_deferred d
             WHERE d.corr_id = 'APPS:oracle.apps.wf.notification.send') de,
           (SELECT o.deq_time out_deq_time,
                   o.enq_time out_enq_time,
                   TO_NUMBER((SELECT str_value
                               FROM TABLE(o.user_data.header.properties)
                              WHERE NAME = 'NOTIFICATION_ID')) o_notification_id,
                   msg_state out_state
              FROM applsys.aq$wf_notification_out o) ou
    WHERE n.notification_id = &NOTIFICATION_ID
       AND n.notification_id = de.d_notification_id(+)
       AND n.notification_id = ou.o_notification_id(+)
    This single query links all together and shows you the current state of the message.
    Column 5 & 6 shows the enqueue & dequeue time of WF_DEFFERRED queue.
    Column 7 shows the message status in WF_DEFFERRED
    Column 8 &  9 shows the enqueue & dequeue time of WF_NOTIFICATIONS_OUT queue.
    Column 10 shows the message status in WF_NOTIFICATION_OUT.
    Below is the sequence of activities going on between the PL/SQL trigger of the business event and the e-mail received from notification mailer in the tail -end
    1. EBS user sends email – To send an email EBS modules use standard API. Email API is implemented in PL/SQL package WF_NOTIFICATION (I will cover it in the next article).
    1.1. Provides application data – First of all user’s session inserts business data (recipient, message type, message text etc.) into WF_NOTIFICATIONS table (do not mix up with PL/SQL package mentioned above);
    1.2. Defers processing Generates event – a user or process leaves EBS to run further email processing steps. It is done using a Business Events System (BES). Session raises an event k“oracle.apps.wf.notification.send” via the WF_EVENT PL/SQL package (BES processing to be covered in the next articles). Each deferred event is put in one of the two Advanced Queues WF_DEFERRED or WF_JAVA_DEFERRED for further processing. All email sending events go through the WF_DEFERRED queue.
    2. Deferred Agent Listener – is a process responsible for ALL BES events processing. It executes all deferred events calling subscriptions’ functions defined for each business event. There are several more things to explain about Agent Listeners and subscription processing (e.g. there are several differed agents, subscriptions groups etc.) This is one more subject for further articles.
    2.1. Reads event and starts subscriptions processing – Strictly speaking there is no any enabled subscription for the “oracle.apps.wf.notification.send” event (submitted during the first step). This event is a part of “oracle.apps.wf.notification.send.group” event group. The Deferred Agent executes subscriptions for that group rather than for the stand alone event. At this stage the Agent knows that it should process the notification with given notification id (it is a part of the event data passed via the event).
    2.2. Reads application data – in order to generate the email/notification the Agent reads business data from the WF_NOTIFICATIONS table and a few related tables and during the next step builds up the email’s text in XML format.
    2.3. Generates data for outbound interface – This is the last step executed by the Deferred Agent Listener. It generates XML representation of email to be sent and together with other important bits of information posts it to the Notification Mailer outbound queue WF_NOTIFICATION_OUT.
    3. Notification Mailer – As you see it was a long journey even before we started to talk about the Notification Mailer. There are a lot of things which may go wrong and this is why it is important to know the whole flow of the events to troubleshoot the mail sending functionality in EBS. We’ve come to the last processing step before the message leaves EBS boundaries.
    3.1. Reads message – the Notification Mailer dequeues messages fromWF_NOTIFICATION_OUT queue on regular basis. In fact this is the only place where it looks for the new messages to be sent. This means if a notification doesn’t has a corresponding event ready for dequeuing in the WF_NOTIFICATION_OUT queue it will never be send. As soon as a new message arrives Notification Mailer dequeues it and gets prepared for sending;
    3.2. Sends email via SMTP – This is the step when the message leaves EBS. The Notification Mailer sends the email using text retrieved from the advanced queue during previous step;
    3.3. Updates status – as the last step in the notification sending process the Notification Mailer updates a MAIL_STATUS column in WF_NOTIFICATION table.

  • Pls tell me how to check the errors in  BDC CALL TRANSACTION

    lemme know

    HI ,
    check for the bold part..
    REPORT ZCONCUR_UPLOAD_TO_SAP NO STANDARD PAGE HEADING
                                 LINE-SIZE 170
                                 LINE-COUNT 58
                                 MESSAGE-ID ZM.
                 Internal Table                                         *
    *-Internal table for the Header input data from the Comma Delimited file
    DATA: BEGIN OF IT_DATA_HEADER OCCURS 0,
              ID    TYPE C,      "Identifier
              BUKRS(6),          "Company Code
              WAERS(7),          "Currency
              NEWKO(12),         "Vendor
              XBLNR(16),         "First Name
              XBLNR1(16),        "Last Name
              BLDAT(12),         "Document/Posting date
              PK(15),            "Reference
              WRBTR(15),         "Amount
              BKTXT(27),         "Doc.header text
              BKTXT1(27),        "Item text
              SELNO(8),          "Serial No
          END OF IT_DATA_HEADER.
    *-Internal table for the item input data from the Comma Delimited file
    DATA: BEGIN OF IT_DATA_ITEM OCCURS 0,
              ID    TYPE C,      "Identifier
              NEWKO(19),         "Vendor
              BUKRS(6),          "Company Code
              KOSTL(12),         "Cost center
              WRBTR(15),         "Amount
              SGTXT(50),         "Text
              SELNO(8),          "Serial No Header
              SELNO1(8),         "Serial No item
          END OF IT_DATA_ITEM      .
    *-Internal table for the Header input data from the Comma Delimited file
    *-Removing " " From Comma Delimited file
    DATA: BEGIN OF IT_FINAL_HEADER OCCURS 0,
              ID     TYPE C,           "Identifier
              BUKRS  LIKE BKPF-BUKRS,  "Company Code
              WAERS  LIKE BKPF-WAERS,  "Currency
              NEWKO  TYPE RF05A-NEWKO, "Vendor
              XBLNR  LIKE BKPF-XBLNR,
              XBLNR1 LIKE BKPF-XBLNR,
              BLDAT(10), " LIKE BKPF-BLDAT,  "Date
              PK(15),                  "Reference
              WRBTR(15),               "Amount
              BKTXT  LIKE BKPF-BKTXT,  "Doc.header text
              BKTXT1 LIKE BKPF-BKTXT,  "Item text
              SELNO  TYPE I,           "Serial No
              FLAG   TYPE C,
          END OF IT_FINAL_HEADER.
    *-Internal table for the Item input data from the Comma Delimited file
    *-Removing " " From Comma Delimited file
    DATA: BEGIN OF IT_FINAL_ITEM OCCURS 0,
              ID     TYPE C,           "Identifier
              NEWKO  TYPE RF05A-NEWKO, "Account
              BUKRS  LIKE BKPF-BUKRS,  "Company Code
              KOSTL  LIKE BSEG-KOSTL,  "Cost Center
              WRBTR(15),               "Amount
              SGTXT  LIKE BSEG-SGTXT,  "Text
              SELNO  TYPE I,           "Serial No
              SELNO1 TYPE I,           "Serial No
          END OF IT_FINAL_ITEM.
    **-Internal table for the  input data from the file
    DATA : BEGIN OF P_DOWNLOAD  OCCURS 0,
            V_FILEREC(1000) TYPE C,
           END OF P_DOWNLOAD.
    *--- Internal Table for Success messages
    DATA : BEGIN OF I_SUCC OCCURS 0,
             HEADER(50),
             MSG(100),                     "SUCCESS message
           END OF I_SUCC.
    *--- Internal Table for error messages
    DATA : BEGIN OF I_ERROR_LOG OCCURS 0,
             HEADER(50),
             MSG(100),                     "Error message
           END OF I_ERROR_LOG.
    *--- Internal table for getting the BDC data
    DATA : BEGIN OF IT_BDCDATA OCCURS 0.
            INCLUDE STRUCTURE BDCDATA.     " Table to hold BDC data
    DATA : END OF IT_BDCDATA.
    *--- Internal table for reading the messages of call transaction
    DATA : BEGIN OF IT_MESSAGE_TAB OCCURS 0.
            INCLUDE STRUCTURE BDCMSGCOLL.  "Table to hold messages
    DATA : END OF IT_MESSAGE_TAB.
                          DATA DECLARATIONS                              *
    DATA:
          V_ERROR_COUNTER   TYPE I,        " error records counter
          V_MSG(100),                      " used for Error message
          V_LINES TYPE I,                  " used for format message
          V_HEAD LIKE SY-CPROG,            " Heading for report
          XMODE VALUE 'N',                 " EXECUTION MODE
          V_SUCCESS_COUNTER TYPE I,        " Success records counter
          V_UNAME LIKE APQI-USERID,        " User Name
          V_TOTAL TYPE I.                  " Total records uploaded
    DATA : V_SELNO TYPE I.
    DATA : V_CHECK TYPE I.
    DATA : V_HEADER(50) TYPE C.             "Header Information
    DATA : V_SUCC_MSG LIKE BDCMSGCOLL-MSGV1."Success Message
    DATA : V_ZERO(4) VALUE '0.00'.          "Checking Zero
    DATA : V_CHECK_ZERO  LIKE BSEG-WRBTR.   "Checking Zero
    DATA : V_CHECK_ZERO1 LIKE BSEG-WRBTR.   "Checking Zero
    DATA : V_SYSTEMDATE  LIKE BKPF-BUDAT.
    DATA : V_VALUE TYPE I.
    DATA : V_VALUE1 TYPE I.
    DATA : V_VALUE2 TYPE I.
    Flags
    DATA:
           F_BDC_OPEN,                   " BDC session open check.
           F_CONTINUE_PROCESSING.        " To continue further processing
                             CONSTANTS                                   *
    CONSTANTS:
           C_SESSION_NAME LIKE APQI-GROUPID VALUE 'F-43',  "Session
           C_X VALUE 'X'.                                  " Used for falgs
                        SELECTION SCREEN                                 *
    *--- Selection Screen with Block and title
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-038.
    PARAMETER: P_FNAME LIKE RLGRAP-FILENAME DEFAULT
                       'C:\Concur.txt'.
    SELECTION-SCREEN END OF BLOCK B1.
    AT SELECTION SCREEN ON VALUE-REQUEST
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAME.
      CALL FUNCTION 'F4_FILENAME'
           IMPORTING
                FILE_NAME = P_FNAME
           EXCEPTIONS
                OTHERS    = 1.
      IF SY-SUBRC <> 0.
        MESSAGE E999 WITH 'Error in opening a file'(009).
      ENDIF.
                              Top-of-page                                *
    TOP-OF-PAGE .
    *---perform to display the standard header
      PERFORM STANDARD_HEADER.
    --START OF SELECTION--
    START-OF-SELECTION.
    Upload data
      PERFORM UPLOAD_DATA.
    move data to bdcdata internal table
      PERFORM MOVE_DATA_F43.
    *--- Posting the valid data to F-43
      IF F_BDC_OPEN = C_X.
    *---perform to close bdc group
        PERFORM CLOSE_GROUP.
      ENDIF.
                             END OF SELECTION                            *
    END-OF-SELECTION.
      CHECK F_CONTINUE_PROCESSING IS INITIAL.
      PERFORM DISPLAY_REPORT.
    *&      Form  MESSAGE_FORMAT
                MESSAGE FORMAT
    FORM MESSAGE_FORMAT.
      CLEAR V_MSG.
      CALL FUNCTION 'FORMAT_MESSAGE'
           EXPORTING
                ID        = IT_MESSAGE_TAB-MSGID
                LANG      = 'EN'
                NO        = IT_MESSAGE_TAB-MSGNR
                V1        = IT_MESSAGE_TAB-MSGV1
                V2        = IT_MESSAGE_TAB-MSGV2
                V3        = IT_MESSAGE_TAB-MSGV3
                V4        = IT_MESSAGE_TAB-MSGV4
           IMPORTING
                MSG       = V_MSG
           EXCEPTIONS
                NOT_FOUND = 1
                OTHERS    = 2.
      IF SY-SUBRC <> 0.
        V_MSG = SPACE.
      ENDIF.
    ENDFORM.                               " MESSAGE_FORMAT
    *&      Form  F4_HELP
    FORM F4_HELP.
      CALL FUNCTION 'WS_FILENAME_GET'
           EXPORTING
                DEF_FILENAME     = ' '
                DEF_PATH         = 'C:\'
                MODE             = 'O'
                TITLE            = TEXT-025  "'Upload File'
           IMPORTING
                FILENAME         = P_FNAME
           EXCEPTIONS
                SELECTION_CANCEL = 3
                SELECTION_ERROR  = 4.
      CASE SY-SUBRC.
        WHEN 3.
          MESSAGE I000 WITH TEXT-007.      " Selection Cancel.
        WHEN 4.
          MESSAGE I000 WITH TEXT-008.      " Selection Error.
      ENDCASE.
    ENDFORM.                                                    " F4_HELP
    *&      Form  STANDARD_HEADER
           STANDARD_HEADER
    FORM STANDARD_HEADER.
      FORMAT COLOR COL_HEADING INTENSIFIED OFF.
      CASE V_HEAD.
        WHEN 'Summary Report'(001).
        WHEN 'SUCC_REPORT'.
    **---To display the field headings for Success report.
          ULINE (154).
          WRITE : /001 SY-VLINE,
                   002 'Header Details '(011),
                   052 SY-VLINE,
                   053 'Document Number'(036),
                  154 SY-VLINE.
          ULINE (154).
        WHEN 'Error Report'.
    **---To display the field headings for error report.
          ULINE (154).
          WRITE : /001 SY-VLINE,
                   002 'Header Details '(011),
                   052 SY-VLINE,
                   053 'Error Message/Text'(035),
                  154 SY-VLINE.
          ULINE (154).
      ENDCASE.
    ENDFORM.                               " STANDARD_HEADER
    *&      Form  DISPLAY_REPORT
          Display Report Details
    FORM DISPLAY_REPORT.
      PERFORM SUMMARY_REPORT.
      PERFORM SUCC_REPORT.
      PERFORM ERROR_REPORT.
    ENDFORM.                               " DISPLAY_REPORT
    *&      Form  SUMMARY_REPORT
           Success & Error Count Number
    FORM SUMMARY_REPORT.
      WRITE : /030 SY-TITLE.
      SKIP 1.
      WRITE : /005 'Program Name : '(032),
               024 SY-REPID,
               080 'Date :'(033),
               088 SY-DATUM.
      SKIP 1.
      V_HEAD = 'Summary Report'(001).
      ULINE (132).
      WRITE : /1 SY-VLINE,
               5 'No. of Records read from the Data file'(014),
               45 ':', V_TOTAL LEFT-JUSTIFIED,
               132 SY-VLINE,
              /1 SY-VLINE,
               5 'No. of Records successfully posted'(015),
               45 ':', V_SUCCESS_COUNTER LEFT-JUSTIFIED,
               132 SY-VLINE,
              /1 SY-VLINE,
               5 'No. of Records Failed'(023),
               45 ':'(031), V_ERROR_COUNTER LEFT-JUSTIFIED,
               132 SY-VLINE.
      IF NOT F_BDC_OPEN IS INITIAL.
        WRITE:  /1 SY-VLINE,
                5 'Session Name'(022),
                45 ':'(031), C_SESSION_NAME LEFT-JUSTIFIED,
                132 SY-VLINE.
      ENDIF.
      ULINE (132).
      IF NOT F_BDC_OPEN IS INITIAL.
        WRITE:  /1 SY-VLINE,
                5 'Session Name'(022),
                45 ':'(031), C_SESSION_NAME LEFT-JUSTIFIED,
                132 SY-VLINE.
      ENDIF.
    ULINE (132).
    ENDFORM.                               " SUMMARY_REPORT
    *&      Form  ERROR_REPORT
          Error Report
    FORM ERROR_REPORT.
      IF NOT I_ERROR_LOG[] IS INITIAL.
        SORT I_ERROR_LOG.                  " by tcode.
        V_HEAD = 'Error Report'(013).
        NEW-PAGE.
        LOOP AT I_ERROR_LOG.
          WRITE: /001 SY-VLINE,
                  002 I_ERROR_LOG-HEADER,
                  052 SY-VLINE,
                  053 I_ERROR_LOG-MSG,
                  154 SY-VLINE.
          ULINE (154).
        ENDLOOP.
      ENDIF.
    ENDFORM.                               " ERROR_REPORT
    *&      Form  ERROR_REPORT
          Success Report
    FORM SUCC_REPORT.
      IF NOT I_SUCC[] IS INITIAL.
        SORT I_SUCC.                  " by tcode.
        V_HEAD = 'SUCC_REPORT'(034).
        NEW-PAGE.
        LOOP AT I_SUCC.
          WRITE: /001 SY-VLINE,
                  002 I_SUCC-HEADER,
                  052 SY-VLINE,
                  053 I_SUCC-MSG,
                  154 SY-VLINE.
          ULINE (154).
        ENDLOOP.
      ENDIF.
    ENDFORM.                               " SUCC_REPORT
    *&      Form  OPEN_SESSION
    FORM OPEN_SESSION.
      DATA : V_DATE LIKE SY-DATUM.         " For Hold Date.
      V_DATE = SY-DATUM - 1.               " Hold date
      V_UNAME = SY-UNAME.                  " User name
      CALL FUNCTION 'BDC_OPEN_GROUP'
           EXPORTING
                CLIENT              = SY-MANDT
                GROUP               = C_SESSION_NAME
                HOLDDATE            = V_DATE
                KEEP                = 'X'
                USER                = V_UNAME
           EXCEPTIONS
                CLIENT_INVALID      = 1
                DESTINATION_INVALID = 2
                GROUP_INVALID       = 3
                GROUP_IS_LOCKED     = 4
                HOLDDATE_INVALID    = 5
                INTERNAL_ERROR      = 6
                QUEUE_ERROR         = 7
                RUNNING             = 8
                SYSTEM_LOCK_ERROR   = 9
                USER_INVALID        = 10
                OTHERS              = 11.
      IF SY-SUBRC <> 0.
        MESSAGE I000 WITH 'Session can not be opened'(019).
        STOP.
      ENDIF.
      F_BDC_OPEN = 'X'.
    ENDFORM.                               " OPEN_SESSION
    *&      Form  BDC_INSERT
    FORM BDC_INSERT USING P_TCODE TYPE ANY.
      CALL FUNCTION 'BDC_INSERT'
           EXPORTING
                TCODE            = P_TCODE
           TABLES
                DYNPROTAB        = IT_BDCDATA
           EXCEPTIONS
                INTERNAL_ERROR   = 1
                NOT_OPEN         = 2
                QUEUE_ERROR      = 3
                TCODE_INVALID    = 4
                PRINTING_INVALID = 5
                POSTING_INVALID  = 6
                OTHERS           = 7.
      IF SY-SUBRC <> 0.
        MESSAGE I000 WITH 'Unable to insert, Error record'(037).
        STOP.
      ENDIF.
    ENDFORM.                               " BDC_INSERT
    *&      Form  CLOSE_GROUP
    FORM CLOSE_GROUP.
      CALL FUNCTION 'BDC_CLOSE_GROUP'
           EXCEPTIONS
                NOT_OPEN    = 1
                QUEUE_ERROR = 2
                OTHERS      = 3.
      IF SY-SUBRC <> 0.
        MESSAGE I000 WITH 'Session can not be closed'(021).
        STOP.
      ENDIF.
    ENDFORM.                               " CLOSE_GROUP
    *&      Form  UPLOAD_DATA
          Upload Data From the text file
    FORM UPLOAD_DATA.
      CALL FUNCTION 'WS_UPLOAD'
           EXPORTING
                FILENAME                = P_FNAME
                FILETYPE                = 'DAT'
           TABLES
                DATA_TAB                = P_DOWNLOAD
           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
                OTHERS                  = 10.
      IF SY-SUBRC NE 0.
        MESSAGE E000 WITH 'File does not Exist'(003).
      ELSEIF P_DOWNLOAD[] IS INITIAL.
        MESSAGE E000 WITH 'Input file is empty'(004).
      ENDIF.
      DATA: V_INDEX LIKE SY-TABIX.
      IF NOT P_DOWNLOAD[] IS INITIAL.
        LOOP AT P_DOWNLOAD.
          V_INDEX = SY-TABIX.
    *Removing double quotes
          DO.
            REPLACE '"' WITH '' INTO P_DOWNLOAD.
            IF SY-SUBRC NE 0.
              EXIT.
            ENDIF.
          ENDDO.
          MODIFY P_DOWNLOAD INDEX V_INDEX.
          CONDENSE P_DOWNLOAD.
          IF P_DOWNLOAD(1) = '1'.
    *Finding the header information, creating key field
            V_SELNO =  SY-TABIX.
          ENDIF.
    WE ARE NOT HAVING KEY FIELD IN HEADER/ITEM IN THE FILE.
    SO WE ARE CREATING MANUAL KEY FIELD IN INTERNAL TABLE (SELNO).
          IF P_DOWNLOAD(1) = '1'.
    Moving header information into IT_DATA_HEADER Internal Table
            SPLIT P_DOWNLOAD AT ',' INTO
                  IT_DATA_HEADER-ID
                  IT_DATA_HEADER-BUKRS
                  IT_DATA_HEADER-WAERS
                  IT_DATA_HEADER-NEWKO
                  IT_DATA_HEADER-XBLNR
                  IT_DATA_HEADER-XBLNR1
                  IT_DATA_HEADER-BLDAT
                  IT_DATA_HEADER-PK
                  IT_DATA_HEADER-WRBTR
                  IT_DATA_HEADER-BKTXT
                  IT_DATA_HEADER-BKTXT1.
            IT_DATA_HEADER-SELNO = V_SELNO.
            CONDENSE : IT_DATA_HEADER-ID,     IT_DATA_HEADER-BUKRS,
                       IT_DATA_HEADER-WAERS,  IT_DATA_HEADER-NEWKO,
                       IT_DATA_HEADER-XBLNR,  IT_DATA_HEADER-XBLNR1,
                       IT_DATA_HEADER-BLDAT,  IT_DATA_HEADER-PK,
                       IT_DATA_HEADER-WRBTR,  IT_DATA_HEADER-BKTXT,
                       IT_DATA_HEADER-BKTXT1, IT_DATA_HEADER-SELNO.
            APPEND IT_DATA_HEADER.
            CLEAR  IT_DATA_HEADER.
          ELSEIF P_DOWNLOAD(1) = '2'.
    Moving header information into IT_DATA_ITEM Internal Table
            SPLIT P_DOWNLOAD AT ',' INTO
                  IT_DATA_ITEM-ID
                  IT_DATA_ITEM-NEWKO
                  IT_DATA_ITEM-BUKRS
                  IT_DATA_ITEM-KOSTL
                  IT_DATA_ITEM-WRBTR
                  IT_DATA_ITEM-SGTXT.
            IT_DATA_ITEM-SELNO  = V_SELNO.
            IT_DATA_ITEM-SELNO1 = SY-TABIX.
            CONDENSE: IT_DATA_ITEM-ID,IT_DATA_ITEM-NEWKO,IT_DATA_ITEM-BUKRS,
                      IT_DATA_ITEM-KOSTL,IT_DATA_ITEM-WRBTR,
                      IT_DATA_ITEM-SGTXT,IT_DATA_ITEM-SELNO,
                      IT_DATA_ITEM-SELNO1.
            APPEND IT_DATA_ITEM.
            CLEAR  IT_DATA_ITEM.
          ENDIF.
        ENDLOOP.
    *SORT HEADER & ITEM INTERNAL Table
        SORT IT_DATA_HEADER BY SELNO.
        SORT IT_DATA_ITEM   BY SELNO SELNO1.
    *Header Information
        LOOP AT IT_DATA_HEADER.
          IT_FINAL_HEADER-ID    = IT_DATA_HEADER-ID.
          IT_FINAL_HEADER-BUKRS = IT_DATA_HEADER-BUKRS.
          IT_FINAL_HEADER-WAERS = IT_DATA_HEADER-WAERS.
          IT_FINAL_HEADER-NEWKO = IT_DATA_HEADER-NEWKO.
          CONCATENATE IT_DATA_HEADER-XBLNR IT_DATA_HEADER-XBLNR1
                      INTO IT_FINAL_HEADER-XBLNR.
          IT_FINAL_HEADER-BLDAT  = IT_DATA_HEADER-BLDAT.
          IT_FINAL_HEADER-PK     = IT_DATA_HEADER-PK.
          IT_FINAL_HEADER-WRBTR  = IT_DATA_HEADER-WRBTR.
          IT_FINAL_HEADER-BKTXT  = IT_DATA_HEADER-BKTXT.
          IT_FINAL_HEADER-BKTXT1 = IT_DATA_HEADER-BKTXT1.
          IT_FINAL_HEADER-SELNO  = IT_DATA_HEADER-SELNO.
          APPEND IT_FINAL_HEADER.
          CLEAR  IT_FINAL_HEADER.
        ENDLOOP.
    *Item Information
        LOOP AT IT_DATA_ITEM.
    CHECKING ZERO IN THE IT_DATA_ITEM-WRBTR FIELD
    It will not append the IT_FINAL_ITEM
          V_CHECK_ZERO = IT_DATA_ITEM-WRBTR.
          IF V_CHECK_ZERO NE V_CHECK_ZERO1. "V_ZERO.
            IT_FINAL_ITEM-ID     = IT_DATA_ITEM-ID.
            IT_FINAL_ITEM-NEWKO  = IT_DATA_ITEM-NEWKO.
            IT_FINAL_ITEM-BUKRS  = IT_DATA_ITEM-BUKRS.
            IT_FINAL_ITEM-KOSTL  = IT_DATA_ITEM-KOSTL.
            IT_FINAL_ITEM-WRBTR  = IT_DATA_ITEM-WRBTR.
            IT_FINAL_ITEM-SGTXT  = IT_DATA_ITEM-SGTXT.
            IT_FINAL_ITEM-SELNO  = IT_DATA_ITEM-SELNO.
            IT_FINAL_ITEM-SELNO1 = IT_DATA_ITEM-SELNO1.
            APPEND IT_FINAL_ITEM.
            CLEAR  IT_FINAL_ITEM.
            CLEAR : V_CHECK_ZERO,V_CHECK_ZERO1.
          ENDIF.
        ENDLOOP.
        SORT IT_FINAL_HEADER BY SELNO.
        SORT IT_FINAL_ITEM BY SELNO.
      ENDIF.
    ENDFORM.                    " UPLOAD_DATA
    *&      Form  MOVE_DATA_F43
          Call Transaction F-43
    FORM MOVE_DATA_F43.
    *MOVE THE SYSTEM DATE TO
      CLEAR V_SYSTEMDATE.
      V_SYSTEMDATE = SY-DATUM.
      LOOP AT IT_FINAL_HEADER.
        CLEAR V_CHECK.
        V_CHECK = IT_FINAL_HEADER-SELNO.
      MOVE HEADER DATA TO BDCDATA INTERNAL TABLE
        PERFORM BDC_BUILD_HEADER.
      MOVE ITEM DATA TO BDCDATA INTERNAL TABLE
        PERFORM BDC_BUILD_ITEM.
    <b>*   Call Transcation (F-43)
        CALL TRANSACTION 'F-43' USING IT_BDCDATA
                                MODE XMODE
                                UPDATE 'S'
                                MESSAGES INTO IT_MESSAGE_TAB.</b>
    IF error record found, it will move to batch Input session
        IF SY-SUBRC <> 0.
          V_ERROR_COUNTER = V_ERROR_COUNTER + 1.      " Inc the counter
          CLEAR V_LINES.
          DESCRIBE TABLE IT_MESSAGE_TAB LINES V_LINES.
          READ TABLE IT_MESSAGE_TAB INDEX V_LINES.
    *--- <b>Perform to read the messages
          PERFORM MESSAGE_FORMAT.</b>*--- Appending the error records into error table
          CONDENSE IT_FINAL_HEADER-BUKRS.
          CONDENSE IT_FINAL_HEADER-NEWKO.
          CONDENSE IT_FINAL_HEADER-XBLNR.
          CONDENSE IT_FINAL_HEADER-BLDAT.
          CONCATENATE IT_FINAL_HEADER-BUKRS ','
                      IT_FINAL_HEADER-NEWKO ','
                      IT_FINAL_HEADER-XBLNR ','
                      IT_FINAL_HEADER-BLDAT
                      INTO V_HEADER.
          I_ERROR_LOG-HEADER = V_HEADER.
          I_ERROR_LOG-MSG = V_MSG.
          APPEND I_ERROR_LOG.
          CLEAR I_ERROR_LOG.
    *--  Posting the error record to Session
          IF F_BDC_OPEN IS INITIAL.
            PERFORM OPEN_SESSION.
          ENDIF.
          PERFORM BDC_INSERT USING 'F-43'.
        ELSE.
          V_SUCCESS_COUNTER = V_SUCCESS_COUNTER + 1.
    *--  READING ONLY SUCCESS MESSAGE(MSGNR 312)
          LOOP AT IT_MESSAGE_TAB WHERE MSGNR = '312'.
            V_SUCC_MSG = IT_MESSAGE_TAB-MSGV1.
          ENDLOOP.
    *--- Perform to read the messages
          PERFORM MESSAGE_FORMAT.
    *--- Appending the Success records into Success table
          CONDENSE IT_FINAL_HEADER-BUKRS.
          CONDENSE IT_FINAL_HEADER-NEWKO.
          CONDENSE IT_FINAL_HEADER-PK.
          CONDENSE IT_FINAL_HEADER-XBLNR.
          CONDENSE IT_FINAL_HEADER-BLDAT.
          CONCATENATE IT_FINAL_HEADER-BUKRS ','
                      IT_FINAL_HEADER-NEWKO ','
                      IT_FINAL_HEADER-PK ','
                      IT_FINAL_HEADER-XBLNR ','
                      IT_FINAL_HEADER-BLDAT
                      INTO V_HEADER.
          I_SUCC-HEADER = V_HEADER.
          I_SUCC-MSG = V_SUCC_MSG.
          APPEND I_SUCC.
          CLEAR  I_SUCC.
        ENDIF.
        V_TOTAL = V_TOTAL + 1.
        REFRESH: IT_BDCDATA,
                 IT_MESSAGE_TAB.
        CLEAR:   IT_BDCDATA,
                 IT_MESSAGE_TAB.
      ENDLOOP.
    ENDFORM.                    " MOVE_DATA_F43
           Start new screen                                              *
    FORM BDC_DYNPRO USING PROGRAM DYNPRO.
      CLEAR IT_BDCDATA.
      IT_BDCDATA-PROGRAM  = PROGRAM.
      IT_BDCDATA-DYNPRO   = DYNPRO.
      IT_BDCDATA-DYNBEGIN = 'X'.
      APPEND IT_BDCDATA.
    ENDFORM.
           Insert field                                                  *
    FORM BDC_FIELD USING FNAM FVAL.
      CLEAR IT_BDCDATA.
      IT_BDCDATA-FNAM = FNAM.
      IT_BDCDATA-FVAL = FVAL.
      APPEND IT_BDCDATA.
    ENDFORM.
    *&      Form  BDC_BUILD_HEADER
          Header Information
    FORM BDC_BUILD_HEADER.
    Header Details
      PERFORM BDC_DYNPRO      USING 'SAPMF05A'    '0100'.
      PERFORM BDC_FIELD       USING 'BDC_OKCODE'  '/00'.
      PERFORM BDC_FIELD       USING 'BKPF-BLDAT'
                                     IT_FINAL_HEADER-BLDAT.
      PERFORM BDC_FIELD       USING 'BKPF-BLART'
                                    'KR'.
      PERFORM BDC_FIELD       USING 'BKPF-BUKRS'
                                    IT_FINAL_HEADER-BUKRS.
    Moveing System date to Posting date in the document
      CLEAR IT_FINAL_HEADER-BLDAT.
      CONCATENATE V_SYSTEMDATE4(4) V_SYSTEMDATE0(4)
                       INTO  IT_FINAL_HEADER-BLDAT.
      PERFORM BDC_FIELD       USING 'BKPF-BUDAT'
                                  IT_FINAL_HEADER-BLDAT.
      PERFORM BDC_FIELD       USING 'BKPF-WAERS'
                                    IT_FINAL_HEADER-WAERS.
      PERFORM BDC_FIELD       USING 'BKPF-XBLNR'
                                    IT_FINAL_HEADER-PK.
      PERFORM BDC_FIELD       USING 'BKPF-BKTXT'
                                    IT_FINAL_HEADER-BKTXT.
      PERFORM BDC_FIELD       USING 'FS006-DOCID'  '*'.
      IF IT_FINAL_HEADER-WRBTR CA '-'.
        REPLACE '-' WITH SPACE INTO IT_FINAL_HEADER-WRBTR.
        CONDENSE IT_FINAL_HEADER-WRBTR.
        PERFORM BDC_FIELD       USING 'RF05A-NEWBS'  '25'.
      ELSE.
        PERFORM BDC_FIELD       USING 'RF05A-NEWBS'  '31'.
      ENDIF.
      PERFORM BDC_FIELD       USING 'RF05A-NEWKO'
                                     IT_FINAL_HEADER-NEWKO.
    *-- Item Vendor Details
      PERFORM BDC_DYNPRO      USING 'SAPMF05A' '0302'.
      PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                    '/00'.
      PERFORM BDC_FIELD       USING 'BSEG-WRBTR'
                                    IT_FINAL_HEADER-WRBTR.
      PERFORM BDC_FIELD       USING 'BSEG-SGTXT'
                                    IT_FINAL_HEADER-BKTXT1.
    ENDFORM.                    " BDC_BUILD_HEADER
    *&      Form  BDC_BUILD_ITEM
          Item Information
    FORM BDC_BUILD_ITEM.
      DATA L_FIRST TYPE C.
      LOOP AT IT_FINAL_ITEM WHERE SELNO = V_CHECK.
        IF L_FIRST IS INITIAL.
          L_FIRST = C_X.
    Line Item ( PstKy,Account & New Company Code)
         CONDENSE IT_FINAL_HEADER-BLDAT.
          IF IT_FINAL_ITEM-WRBTR CA '-'.
            REPLACE '-' WITH SPACE INTO IT_FINAL_ITEM-WRBTR.
            CONDENSE IT_FINAL_ITEM-WRBTR.
            PERFORM BDC_DYNPRO    USING  'SAPMF05A'    '0302'.
            PERFORM BDC_FIELD     USING: 'BDC_OKCODE'   '/00',
                                         'RF05A-NEWBS'  '50',
                                         'RF05A-NEWKO'  IT_FINAL_ITEM-NEWKO,
                                         'RF05A-NEWBK'  IT_FINAL_ITEM-BUKRS.
          ELSE.
            PERFORM BDC_DYNPRO    USING  'SAPMF05A'    '0302'.
            PERFORM BDC_FIELD     USING: 'BDC_OKCODE'   '/00',
                                         'RF05A-NEWBS'  '40',
                                         'RF05A-NEWKO'  IT_FINAL_ITEM-NEWKO,
                                         'RF05A-NEWBK'  IT_FINAL_ITEM-BUKRS.
          ENDIF.
    Amount & Text
          PERFORM BDC_DYNPRO    USING  'SAPMF05A' '0300'.
          PERFORM BDC_FIELD     USING: 'BDC_OKCODE'   '/00',
                                       'BSEG-WRBTR'   IT_FINAL_ITEM-WRBTR,
                                       'BSEG-SGTXT'   IT_FINAL_ITEM-SGTXT,
                                       'DKACB-FMORE'  'X'.
    Cost Center
          PERFORM BDC_DYNPRO    USING  'SAPLKACB'    '0002'.
          PERFORM BDC_FIELD     USING: 'BDC_OKCODE' 'ENTE',
                                       'COBL-KOSTL' IT_FINAL_ITEM-KOSTL.
        ELSE.
    Line Item ( PstKy,Account & New Company Code)
          IF IT_FINAL_ITEM-WRBTR CA '-'.
            REPLACE '-' WITH SPACE INTO IT_FINAL_ITEM-WRBTR.
            CONDENSE IT_FINAL_ITEM-WRBTR.
            PERFORM BDC_DYNPRO    USING  'SAPMF05A'    '0300'.
            PERFORM BDC_FIELD     USING: 'BDC_OKCODE'   '/00',
                                         'RF05A-NEWBS'  '50',
                                         'RF05A-NEWKO'  IT_FINAL_ITEM-NEWKO,
                                         'RF05A-NEWBK'  IT_FINAL_ITEM-BUKRS.
          ELSE.
            PERFORM BDC_DYNPRO    USING  'SAPMF05A'    '0300'.
            PERFORM BDC_FIELD     USING: 'BDC_OKCODE'   '/00',
                                         'RF05A-NEWBS'  '40',
                                         'RF05A-NEWKO'  IT_FINAL_ITEM-NEWKO,
                                         'RF05A-NEWBK'  IT_FINAL_ITEM-BUKRS.
          ENDIF.
          PERFORM BDC_DYNPRO    USING  'SAPLKACB'   '0002'.
          PERFORM BDC_FIELD     USING: 'BDC_OKCODE' 'ENTE'.
    Amount & Text
          PERFORM BDC_DYNPRO    USING  'SAPMF05A'    '0300'.
          PERFORM BDC_FIELD     USING: 'BDC_OKCODE'  '/00',
                                       'BSEG-WRBTR'  IT_FINAL_ITEM-WRBTR,
                                       'BSEG-SGTXT'  IT_FINAL_ITEM-SGTXT,
                                       'DKACB-FMORE' 'X'.
    Cost Center
          PERFORM BDC_DYNPRO    USING  'SAPLKACB'    '0002'.
          PERFORM BDC_FIELD     USING: 'BDC_OKCODE' 'ENTE',
                                       'COBL-KOSTL' IT_FINAL_ITEM-KOSTL.
        ENDIF.
      ENDLOOP.
    *Save Details
      PERFORM BDC_DYNPRO        USING  'SAPMF05A' '0300'.
      PERFORM BDC_FIELD         USING  'BDC_OKCODE'
                                       '=BU'.
      PERFORM BDC_DYNPRO        USING  'SAPLKACB'    '0002'.
      PERFORM BDC_FIELD         USING: 'BDC_OKCODE' 'ENTE'.
    ENDFORM.                    " BDC_BUILD_ITEM
    Thanks
    Mahesh

Maybe you are looking for

  • Extractor for Product Group/Member Allocation- hierarchy (table u2013 PGMI ).

    Hello experts I am looking for standard extractor for Product Group/Member Allocation- hierarchy (table u2013 PGMI on the ECC). Is there a standard extractor for product group-hierarchy? Best Regards, Tal Shalom.

  • Excel mail merge

    how do i print envelopes using an existing excel spreadsheet?

  • I use Windows vista

    how can I get photos on my PC into the cloud ( icloud control panel is for windows 7 or above!!)

  • Error message: "Please review your billing information and approve it"

    I keep getting this message and I'm pulling my hair out. It says my account information has changed. My account information changed because I was having trouble ordering a book when iPhoto suddenly decided to decline my credit card even though I had

  • Communication channel name

    hi experts,                     can two communication channels in different scenarios have same name? i had configured two different channels with same name in diffent scenarios ? does this work? please help