Urgent ---group by syntax error

This is my syntax as below.But it doesn't work.Does anyone can tell me what's problem ? or it have another way to solve this quuestion? thanks .
sql syntax:
select a.txdate,a.costype,sum(cosamt) * (1+a.cosrate) as costamount
from sales_cost a
where a.txdate between '2003-01-01' and '2003-02-01'
group by a.txdate,a.costype;

Although more specifics might have helped, I am assuming based on the title of the post: "urgent ---group by syntax error" and my test of the original code that I have identified the error. See the example below for how the original code produces a group by error and how the solution I provided executes without error.
SQL> -- test data:
SQL> SELECT * FROM sales_cost
  2  /
TXDATE      COSTYPE    COSAMT   COSRATE                                                            
03-JAN-03         1         3        .5                                                            
03-JAN-03         1         4       .25                                                            
03-JAN-03         2         4       .75                                                            
04-JAN-03         3         3        .5                                                            
04-JAN-03         4         4       .25                                                            
04-JAN-03         4         4       .75                                                            
6 rows selected.
SQL> --
SQL> --
SQL> -- wrong:
SQL> SELECT   a.txdate, a.costype,
  2             SUM (a.cosamt) * (1 + a.cosrate) AS costamount
  3  FROM     sales_cost a
  4  WHERE    a.txdate BETWEEN '2003-01-01' AND '2003-02-01'
  5  GROUP BY a.txdate,a.costype
  6  /
         SUM (a.cosamt) * (1 + a.cosrate) AS costamount
ERROR at line 2:
ORA-00979: not a GROUP BY expression
SQL> --
SQL> --
SQL> -- correct:
SQL> SELECT   a.txdate, a.costype,
  2             SUM (a.cosamt * (1 + a.cosrate)) AS costamount
  3  FROM     sales_cost a
  4  WHERE    a.txdate BETWEEN TO_DATE ('2003-01-01', 'YYYY-MM-DD')
  5                   AND     TO_DATE ('2003-02-01', 'YYYY-MM-DD')
  6  GROUP BY a.txdate,a.costype
  7  /
TXDATE      COSTYPE COSTAMOUNT                                                                     
03-JAN-03         1        9.5                                                                     
03-JAN-03         2          7                                                                     
04-JAN-03         3        4.5                                                                     
04-JAN-03         4         12                                                       

Similar Messages

  • Rownum and group by syntax error

    Hi,
    I have a query, which use Oracle rownum.
    if I put the group by clause to inner select clause, it does not work.
    select PS1.PO_ID, PS1.PO_DATE, PS1.POD_PO_ID, sum(PO_ID)
    from ( select rownum r_ , A.PO_ID, A.PO_DATE, B.POD_PO_ID
    from OPS$RS3.DTINV_PO_DETAIL B, OPS$RS3.DTINV_PO A
    where (A.PO_ID <= '450')
    group by A.PO_ID, A.PO_DATE,B.POD_PO_ID
    ) PS1
    where r_ > 0 AND r_ <= 10
    but if I put the group by clause outside, it work. but this is not what I want.
    select PS1.PO_ID, PS1.PO_DATE, PS1.POD_PO_ID, sum(PO_ID)
    from ( select rownum r_ , A.PO_ID, A.PO_DATE, B.POD_PO_ID
    from OPS$RS3.DTINV_PO_DETAIL B, OPS$RS3.DTINV_PO A
    where (A.PO_ID <= '450')
    ) PS1
    where r_ > 0 AND r_ <= 10
    group by A.PO_ID, A.PO_DATE,B.POD_PO_ID
    Can anybody explain why?
    Thanks!
    xiong

    select PS1.PO_ID
          ,PS1.PO_DATE
          ,PS1.POD_PO_ID
          ,sum(PO_ID)
    from  (select rownum r_
                 ,A.PO_ID
                 ,A.PO_DATE
                 ,B.POD_PO_ID
           from   OPS$RS3.DTINV_PO_DETAIL B
                 ,OPS$RS3.DTINV_PO A
           where (A.PO_ID <= '450')
           group  by A.PO_ID
                    ,A.PO_DATE
                    ,B.POD_PO_ID
          ) PS1
    where r_ > 0 AND r_ <= 10I don't get what you're trying to do here.
    First of all, you have no join condition between the A and B tables of your inline view. That's a cartesian product, probably not what you want.
    Also, why do you have '450' in quote marks? Is a.po_id a varchar2 column?
    You can't do a GROUP BY like this with rownum in your select list. It doesn't make any sense.
    Why do you want row numbers between 1 and 10? Those are just 10 arbitrary rows not based on anything. Or is that what you want?

  • EDI: Syntax error in IDoc (mandatory group/segment missing)

    hi EDI/IDoc experts,
    Need you help urgently. According to the requirement, i need populate a segement  E1IDT01 of basic type PEXR2002 . I added the code , then run and generate an idoc , the new segment
    E1IDT01  was populated,  but Syntax error 26 happend. Error message as below.   It also strange that i can see E1IDKU5 populate out as usual, but some others segment disappeared , i am sure that in my code ,i didn't changed any variable related to other segement . how can i fix this problem?
    EDI: Syntax error in IDoc (mandatory group missing)
    Message no. E0079
    Diagnosis
    The segment group E1IDKU5 has the attribute 'Mandatory' in the syntax description of the basic type PEXR2002 (customer enhancement ). However, the segment group is missing in the IDoc. The segment number logged in the status record identifies the item before which the segment group is missing.
    Procedure
    Please check the IDoc or the syntax description of the basic type PEXR2002 (customer enhancement ).

    Hi all,
    Thanks so much for your concern!
    Finally ,this problem has been figured out  .
    Requirement is user want to use segment E1IDT01 in idoc to populate the long text they maintained in accounting document vendor item line (use FB01 to create accounting doc).
    Why I made out " EDI: Syntax error in IDoc (mandatory group/segment missing)" this message out ,because  I didn't fill data correctly. I missed to keep SY-TABIX in momory .
    when we use Function module ,or do..enddo...or read table it_table. we should be careful that SY-TABIX  is changed .So we can't just use MODIFY EDIDD_TABLE INDEX  SY-TABIX  in the last . we should define a local variable to keep  SY-TABIX  in memory and then use it to modify EDIDD_TABLE. 
    Follow is the final code.
    IF SEGMENT_NAME = 'E1IDT01'.
    TABLES :STXL.
    * Define for long text getting
      DATA: LIT_TLINE  LIKE TLINE   OCCURS 0 WITH HEADER LINE.
      DATA: LV_STRING(2000)  TYPE C.                          
      DATA: LV_TDNAME TYPE THEAD-TDNAME,
            LV_ID     TYPE THEAD-TDID     VALUE '0001',
            LV_LANG   TYPE THEAD-TDSPRAS  VALUE 'E' ,
            LV_OBJ    TYPE THEAD-TDOBJECT VALUE 'DOC_ITEM'.
    data:   LV_LINE   TYPE I,                " long Text lines
            LV_LEN    TYPE I,                " long Text length   
            LV_TABIX  LIKE SY-TABIX.                              
    * Clear memory
      CLEAR:LV_TDNAME,
            LV_STRING,                                        
            LV_LINE,                                           
            LIT_TLINE, LIT_TLINE[],                          
            LV_LEN,                                            
            LV_TABIX.                                        
    * Keep sy-tabix memory using a variable--This is the key point
      LV_TABIX = SY-TABIX.
    * Combine TDNAME with company code + accounting doc + fiscal year + item number.
        CONCATENATE  REGUP_DATA-BUKRS REGUP_DATA-BELNR
                     REGUP_DATA-GJAHR REGUP_DATA-BUZEI INTO  LV_TDNAME.
    * When vendor item has long text , read long text into lv_string
        SELECT SINGLE *
          FROM STXL
          WHERE TDOBJECT = LV_OBJ
            AND TDNAME   = LV_TDNAME
            AND TDID     = LV_ID
            AND TDSPRAS  = 'E'.
        IF SY-SUBRC = 0.
          CALL FUNCTION 'READ_TEXT'
            EXPORTING
              CLIENT   = SY-MANDT
              ID       = LV_ID
              LANGUAGE = LV_LANG
              NAME     = LV_TDNAME
              OBJECT   = LV_OBJ
            TABLES
              LINES    = LIT_TLINE.
          IF NOT LIT_TLINE[] IS INITIAL.
            DESCRIBE  TABLE LIT_TLINE LINES LV_LINE.
            DO LV_LINE TIMES.
              READ TABLE LIT_TLINE INDEX SY-INDEX.
              CONCATENATE LV_STRING LIT_TLINE-TDLINE INTO LV_STRING.
            ENDDO.
            LV_LEN = STRLEN( LV_STRING ).
    * Make sure we only need  less than 840 charicters
            IF LV_LEN > 840.
              LV_STRING = LV_STRING+0(840).
              LV_LEN    = 840.
            ENDIF.
    * Populate Vendor item long text with segment E1IDT01 start from
    * Fields TXT03 to TXT14.
             EDIDD_TABLE-SDATA+147(LV_LEN) = LV_STRING.
            MODIFY EDIDD_TABLE INDEX LV_TABIX.
          ENDIF.
        ENDIF.
      ENDIF.

  • "Syntax error in the MDX statement " in Process chain failure??Urgent pls

    Hi Experts,
    could any one suggest me the procedure to rectify the below problems in process chain?
    1."Syntax error in the MDX statement "
    2."Error when getting data (Error when getting data (AXI))"
    Rgds,
    BH

    In which case it'll be that Access has a different date format to MySQL, and you're trying to push the string "'25-Apr-12 10:55 PM" into Access, which it's not understanding. To get around this, you need to treat your variable as a true date/time object, rather than a formatted string.
    CFQueryParams should be used on absolutely every database platform, they'll stop your website being vulnerable to SQL Injection attacks for one, which at the moment you're wide open to. Replace your query with something like this:
    <cfquery name="input_comments" datasource="#DSN#" username="#DSNUSER#" password="#DSNPASS#">
          INSERT INTO comments(
                             commenter,
                             comment,
                             datetime,
                             post_id
                   VALUES(
                             <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.commenter#" />,
                             <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.comment#" />,
                             now(),
                             <cfqueryparam cfsqltype="cf_sql_numeric" value="#form.post_id#" /> )
    </cfquery>
    The QueryParams will handle the data types for you, and should pass values around more safely and with fewer issues. Assuming you just want to store the current date and time you don't even need to get ColdFusion involved, as databases have their own functions for this. I believe Access' version is simply NOW(), so I've put that in your query.
    Give the above a go.

  • EDI: Syntax error in IDoc (mandatory group missing)

    Hi Idoc Experts !
    The error pasted in subject is what i'm getting when i'm calling function module MASTER_IDOC_DISTRIBUTE.
    THE IDOC IS GETTING GENERATED BUT HAS SYNTAX ERRORS WITH STATUS/ERROR CODE :26.
    I'm tryin to generate an IDOC with following details:
    Direction         1     Outbox
    Current status    26
    Basic type        WMMBID02
    Extension
    Message type      WMMBXY
    Partner no.       XEROX
    Partn.Type        LS
    Port              170_INVRPT
    Can anyone be of some help?
    Points guaranteed for authentic answers !
    Thanks,
    Sachin Soni

    Hi,
    While passing the idoc data, you are not passing the mandatory segment and passing the child segment. Try to add the data for the mandatory segment.
    Check and find the mandatory segments on the IDoc through WE30 .And check if all this segments are populated in the IDoc which failed ( WE02).
    Regards,
    Soumya.

  • Syntax error in OBIEE generated Physical query - Advance filter concept

    I encountered a syntax error when running a report with the help of advanced filter concept.
    I am getting syntax error at the physical query generated by the OBIEE for main report.
    I used a sub report with the help of advanced filter concept in main report.
    I am posting the physical query for the convenience.
    select D1.c2 as c1,
    D1.c1 as c2
    from
    (select sum(T600347.sales_usd) as c1,
    T601002.currency as c2
    from
    (Select distinct currency from pfact) T601002,
    pfact T600347
    where ( T600347.currency = T601002.currency and T600347.pdate between ( select distinct min(D1.c1) as c1* from
    (select D1.c1 as c1
    from
    (select D1.c1 as c1
    from
    *(select max(T600425.pdate) as c1*
    from
    *(select distinct pdate from pdates where pdate is not null) T600425*
    where  ( T600425.pdate < 11/22/2010 )
    *) D1*
    ) D1
    ) D1 ) and '11/25/2010')
    group by T601002.currency
    ) D1
    I executed the query against my database(sybase) in query tool. It showed error.
    I took out the column alias generated by the OBIEE ("as c1" as underlined). Then the query is working fine.
    How to disable OBIEE from generating the alias.
    Is there any way to do it.
    If obiee is generating the physical query, i am suprised to see a syntax error.
    The bold part is the query from Intermediate report
    I underlined the problematic part.
    Please help me. This is an urgent reuirement,
    Thanks in advance for the help.

    HI,
    When I execute the query on query tool ( my database is sybase)
    I am geting error at "as c1" part, as underlined in the query.
    when I remove that and execute the query, It is generating the output.
    here is the better view of query and error:
    http://img255.imageshack.us/img255/4719/25187227.jpg

  • Syntax Error in Include which is genarated by System

    Hi,
    Good day experts,
    now iam working on EVENTS in IS-U module.
    FUNCTION Module : yfkk_sample_9560 .
    ""Local interface:
    *"  IMPORTING
    *"     REFERENCE(I_FKKOP) TYPE  FKKOP
    *"     REFERENCE(I_FIELDCAT) TYPE  FKKSP_FIELDS
    *"     REFERENCE(I_KEYDATE) TYPE  OP_KEYDATE_KK OPTIONAL
    *"  CHANGING
    *"     REFERENCE(C_FKKOPRU) TYPE  FKKOPRU
    *types:fkksp_fields type table of fkksp_s_fields.
    Example:
    DATA:
       wa_cat TYPE fkksp_s_fields.
    READ TABLE i_fieldcat INTO wa_cat
       WITH KEY orig_field = 'PARTNER_NAME' orig_table = 'FKKOPRU'.
    IF sy-subrc = 0.
       SELECT SINGLE field
         INTO c_fkkopru-partner_name
         FROM table
         WHERE gpart = i_fkkop-gpart.
    ENDIF.
    GETTING CITY1  ********************
       DATA:
            wa_cat type fkksp_s_fields. "#EC *
       DATA: wa_fkkop TYPE fkkop. "#EC *
       DATA: x_haus LIKE ehauisu-haus, "#EC *
             x_actual LIKE regen-actual. "#EC *
       DATA:lv_vkonto TYPE ever-vkonto. "#EC *
       TABLES: ever,eanl,evbs. "#EC *
       DATA: lv_anlage TYPE eanl-anlage, "#EC *
             lv_vstelle TYPE eanl-vstelle. "#EC *
       DATA: yv_vstelle TYPE evbs-vstelle, "#EC *
             lv_haus    TYPE evbs-haus, "#EC *
             yy_addr_data TYPE eadrdat, "#EC *
             y_ehauisu TYPE ehauisu, "#EC *
             x_portion TYPE te420-termschl, "#EC *
             lv_vkont TYPE fkkvkp-vkont. "#EC *
       DATA: t_ever LIKE ever OCCURS 0 WITH HEADER LINE, "#EC *
             t_eanl LIKE eanl OCCURS 0 WITH HEADER LINE, "#EC *
             t_evbs LIKE evbs OCCURS 0 WITH HEADER LINE, "#EC *
             t_iflot LIKE iflot OCCURS 0 WITH HEADER LINE. "#EC *
      DATA: y_anlage TYPE eablg-anlage, "#EC *
            y_ableinh TYPE eablg-ableinh, "#EC *
            y_portion TYPE te422-portion. "#EC *
    ****Getting the city 1 *******************
    *LOOP AT I_FKKOP INTO WA_FKKOP.
       CALL FUNCTION 'ISU_GET_PARTNER_ADDRESS'
         EXPORTING
           x_partnerid        = i_fkkop-gpart
           x_addrnumber       = i_fkkop-emadr
      X_PERSNUMBER       =
        IMPORTING
      Y_NAME             =
      Y_ADDR_LINES       =
          y_addr_data        = yy_addr_data .
    *******Getting the connection object**************
       CALL FUNCTION 'YISU_GETCONNOBJ_VKONTGPART'
         EXPORTING
           i_vkont        = i_fkkop-vkont
           i_gpart        = i_fkkop-gpart
      IMPORTING
        E_BUTOOO       =
        E_FKKVKP       =
         TABLES
           t_ever         = t_ever
           t_eanl         = t_eanl
           t_evbs         = t_evbs
           t_iflot        = t_iflot
       lv_haus = t_evbs-haus.
    Getting the Political Word***************
       CALL FUNCTION 'ISU_DB_EHAUISU_SINGLE'   "#EC *
         EXPORTING
           x_haus          = lv_haus
          X_ACTUAL        = ' '
        IMPORTING
          y_ehauisu       = y_ehauisu
      EXCEPTIONS
       not_found       = 1
       OTHERS          = 2.
       IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
       ENDIF.
    ***********Getting the Potion******************
       SELECT SINGLE anlage "#EC *
                     ableinh FROM eablg INTO (y_anlage, y_ableinh) WHERE anlage = t_eanl-anlage.
       IF sy-subrc = 0.
         SELECT SINGLE portion FROM te422 INTO y_portion WHERE termschl = y_ableinh.
       ENDIF.
    ***************Assinging the city1 and political word and portion ***********
       READ TABLE i_fieldcat INTO wa_cat WITH KEY
           orig_field = 'YYCITY1'    orig_table = 'FKKOPRU'
           orig_field = 'YYREGPOLIT' orig_table = 'FKKOPRU'
           orig_field = 'YYPORTION'  orig_table = 'FKKOPRU'.
       IF sy-subrc = 0.
         c_fkkopru-yycity1 = yy_addr_data-city1.
         c_fkkopru-yyregpolit = y_ehauisu-regpolit.
         c_fkkopru-yyportion = y_portion.
       ENDIF.
    ENDFUNCTION.
    Here iam getting the syntax error but activation wont get any error.
    Error is : "FKKSP_FIELDS" is not a pre-defined type or a type from a type group.          
    Plz its very urgent. give me solution for this Error.
    Regards,
    kk

    Hi,
    You need to declare the type group FKKSP in the global include.  i.e.
    TYPE-POOLS FKKSP.
    Regards,
    Dion

  • Syntax error in start routine

    Dear All,
    I have activated the infocube 0sd_c03 with grouping "in data flow before" and the infocube is activated with datasources
    2LIS_11_VAITM
    2LIS_11_VAHDR
    2LIS_12_VCITM
    2LIS_12_VCHDR
    2LIS_13_VDITM
    2LIS_13_VDHDR in 3.x where as
    TRCS 2LIS_13_VDITM -> CUBE 0SD_C03 in transformation with DTP.
    when I activate the transformation I get error as mentioned below:
    Start Routine: Syntax error in routine and in the start routine when I check the details of the error is
                      E:In PERFORM or CALL FUNCTION "ROUTINE_9998", the actual parameter
                               "SOURCE_PACKAGE" is incompatible with the formal parameter
                                   "DATA_PACKAGE".
    If source pakage is replaced by data package the system message is data_package is not available.
    What do I do to resolve this issue.
    KS

    hi,
    There is a structral diffrence between SOURCE_PACKAGE and DATA_PACKAGE
    so you need to change tys_SC_1_full
    go through the below links for similar problem
    Re: 0IC_C03: 2LIS_03_BF Transformation Start Routine Activation error
    Re: 2LIS_03_BF transformation problem

  • Basis SP 18 to 20, can not logon through SAPGUI - Syntax Error

    Hello Experts,
    We had started ECC6.0 SP18 to SP20 patches and now we are getting Syntax error in program "CL_WB_CROSSREFERENCE==========CP ". for most of the transactions executed.
    1. Job RDDIMPDP is also failing with message
    Program RDDIMPDP is running in client 000                                    
    Context TERNAL_INFOS does not contain any fields                     
    Context TERNAL_INFOS contains errors and could therefore not be generated     
    Context BANK_CTX_JC_REPORT modified                                           
    Internal session terminated with a runtime error (refer to ST22)         
    Job cancelled                                                   
    2. Here are the details of this short dump, as soon as we get the short dump we get message in the status bar saying "Context BANK_CTX_JC_REPORT modified".
    Error in the ABAP Application Program                                                                               
    The current ABAP program "SAPLSEWB" had to be terminated because it has                       
        come across a statement that unfortunately cannot be executed.                                                                               
    The following syntax error occurred in program                                                
         "CL_WB_CROSSREFERENCE==========CP " in include                                               
         "CL_WB_CROSSREFERENCE==========CM005 " in                                                    
        line 7:                                                                               
    ""PROGRAM-" expected, not "PROGNAME_""                                                        
    The include has been created and last changed by:                                             
        Created by: "SAP "                                                                               
    Last changed by: "PEARSONA "                                                                  
        Error in the ABAP Application Program                                                                               
    The current ABAP program "SAPLSEWB" had to be terminated because it has                       
        come across a statement that unfortunately cannot be executed.                                
    Error analysis                                                                               
    The following syntax error was found in the program                                           
         CL_WB_CROSSREFERENCE==========CP :                                                           
        ""PROGRAM-" expected, not "PROGNAME_""                                                        
    Trigger Location of Runtime Error                                                                 
        Program                                 SAPLSEWB                                              
        Include                                 LSEWBU07                                              
        Row                                     837                                                   
        Module type                             (FORM)                                                
        Module Name                             PROGRAM_ACTUALIZE                                     
    Source Code Extract                                                                               
    Line  SourceCde                                                                               
    807 * PROGRAM_ACTUALIZE, ADD_CHILDS und PG_COMPONENT verwendet                                  
      808                                                                               
    809   previous_id = '1'.                                                                        
      810   xtype = 'C'.                                                                               
    811   IF xprogram(4) = 'SAPL' OR xprogram+1 CS '/SAPL'.                                         
      812 *   Funktionsgruppennamen bestimmen                                                         
      813     l_program = xprogram.                                                                   
      814     CALL FUNCTION 'FUNCTION_INCLUDE_SPLIT'                                                  
      815       EXPORTING                                                                               
    816         program   = l_program                                                               
      817       IMPORTING                                                                               
    818         namespace = l_namespace                                                             
      819         group     = l_area                                                                  
      820       EXCEPTIONS                                                                               
    821         OTHERS    = 6.                                                                      
      822     IF sy-subrc = 0.                                                                        
      823       xtype+1(1) = 'F'.                                                                     
      824     ELSE.                                                                               
    825       xtype+1(1) = 'P'.                                                                     
      826     ENDIF.                                                                               
    827   ELSEIF current_treename(3) = 'CP_'.                                                       
      828     xtype+1(1) = 'O'.                                                                       
      829   ELSE.                                                                               
    830     xtype+1(1) = 'P'.                                                                       
      831   ENDIF.                                                                               
    832                                                                               
    833   IF without_crossreference IS INITIAL.                                                     
      834     IF scros_new_where_used_list = 'X' AND index_parallel EQ space.                         
      835 *     neuer Index Verwendungsnachweis                                                       
      836       lprogram = xprogram.                                                                  
    >>>>>       CALL METHOD cl_wb_crossreference=>program_index(                                      
      838         EXPORTING                                                                           
      839           p_name             = lprogram    " Programmname                                   
      840         IMPORTING                                                                           
      841           p_error            = l_error    " Fehler Index wurde nicht aufgebaut              
      842         EXCEPTIONS                                                                          
      843           program_name_empty = 1                                                            
      844           OTHERS             = 2                                                            
      845             ).                                                                               
    846       IF sy-subrc <> 0.                                                                     
      847 *        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno                                  
      848 *                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.                               
      849       ENDIF.                                                                               
    850     ENDIF.                                                                               
    851   ENDIF.                                                                               
    852                                                                   
    3. Tried to generate the program manually through SE38 -> CL_WB_CROSSREFERENCE==========CP  --> but it dumps with same message line 7:                                                                               
    ""PROGRAM-" expected, not "PROGNAME_"" 
    Appreciate your inputs in resolving this issue.
    Raised message with SAP support but didn't hear anything till now - so seeking your experise.
    Best Regards
    Davinder

    Hello Experts,
    Further investigation on system showed that we had implemented SNOTE 1374978 - which seems to be causing the problem.
    Now as Support packages (SPAM) has locked SNOTE transactions also - is there any way that we can deimplement the above sap note from our system.
    Thanks
    Davinder

  • Syntax error

    Hi abappers
    I am using the following code in my program.
    i  m getting a syntax error that i do not understand? can any body help me out with this.
    Regards
    Narendiran Rathinavelu
    *& Report  ZTEST_RECUPLOAD
    REPORT  ZTEST_RECUPLOAD.
    *include bdcrecx1.
    ******************Selection screen************************************
    SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME TITLE TEXT-T01 .
    PARAMETERS P_FILE   TYPE RLGRAP-FILENAME OBLIGATORY.
    PARAMETERS P_SESSN  TYPE APQI-GROUPID DEFAULT 'RECURRING'.
    PARAMETERS P_SESSN2 TYPE APQI-GROUPID DEFAULT 'RECURRING_E'.
    SELECTION-SCREEN END OF BLOCK 1.
    ********************Type declaration**********************************
    *type for data input table
    TYPES : BEGIN OF TY_DATA,
            BUKRS    TYPE T001-BUKRS,         "Company code
            BLART    TYPE BKPF-BLART,         "Document type
           BUDAT    TYPE BKPF-BUDAT,         "Posting date
            DBBDT    TYPE BKDF-DBBDT,         "First run
            DBATR    TYPE BKDF-DBATR,         "Next run
            DBEDT    TYPE BKDF-DBEDT,         "last run
            DBMON    TYPE BKDF-DBMON,         "Run frequency
            DBTAG    TYPE BKDF-DBTAG,         "Run date
           DBZHL    TYPE BKDF-DBZHL,         "no of runs
            XBLNR    TYPE BKPF-XBLNR,         "reference(site)
            BKTXT    TYPE BKPF-BKTXT,         "document header data
           USNAM    TYPE BKPF-USNAM,         "User name
           CPUDT    TYPE BKPF-CPUDT,         "Entry date
            BSCHL_1  TYPE BSEG-BSCHL,         "Posting key 1 item
            HKONT_1  TYPE BSEG-HKONT,         "Account 1 item
            DESC_1   TYPE CHAR40,             "Description vendor/GL 1 item
            MWSKZ_1  TYPE BSEG-MWSKZ,         "Tax code 1 item
           MWSTS1_1 TYPE BSEG-MWSTS,         "Tax Amount 1 item
            MWSTS2_1 TYPE BSEG-MWSTS,         "Amount is local currency 1 item
           MWSTS3_1 TYPE BSEG-MWSTS,         "Amount is foreign currency 1 item
            SGTXT_1  TYPE BSEG-SGTXT,         "Item text 1 item
            ZUONR_1  TYPE BSEG-ZUONR,         "Assignment 1 item
            BSCHL_2  TYPE BSEG-BSCHL,         "Posting key 2 item
            HKONT_2  TYPE BSEG-HKONT,         "Account 2 item
            DESC_2   TYPE CHAR40,             "Description vendor/GL 2 item
            MWSKZ_2  TYPE BSEG-MWSKZ,         "Tax code 2 item
           MWSTS1_2 TYPE BSEG-MWSTS,         "Tax Amount 2 item
            MWSTS2_2 TYPE BSEG-MWSTS,         "Amount is local currency 2 item
           MWSTS3_2 TYPE BSEG-MWSTS,         "Amount is foreign currency 2 item
            KOSTL    TYPE COBL-KOSTL,         "Cost center
            AUFNR    TYPE COBL-AUFNR,         "Internal order number
            SGTXT_2  TYPE BSEG-SGTXT,         "Item text 2 item
            ZUONR_2  TYPE BSEG-ZUONR,         "Assignment 2 item
          END OF TY_DATA.
    *type for data error table
    TYPES : BEGIN OF TY_ERROR,
             BUKRS    TYPE T001-BUKRS,         "Company code
            BLART    TYPE BKPF-BLART,         "Document type
           BUDAT    TYPE BKPF-BUDAT,         "Posting date
            DBBDT    TYPE BKDF-DBBDT,         "First run
            DBATR    TYPE BKDF-DBATR,         "Next run
            DBEDT    TYPE BKDF-DBEDT,         "last run
            DBMON    TYPE BKDF-DBMON,         "Run frequency
            DBTAG    TYPE BKDF-DBTAG,         "Run date
           DBZHL    TYPE BKDF-DBZHL,         "no of runs
            XBLNR    TYPE BKPF-XBLNR,         "reference(site)
            BKTXT    TYPE BKPF-BKTXT,         "document header data
           USNAM    TYPE BKPF-USNAM,         "User name
           CPUDT    TYPE BKPF-CPUDT,         "Entry date
            BSCHL_1  TYPE BSEG-BSCHL,         "Posting key 1 item
            HKONT_1  TYPE BSEG-HKONT,         "Account 1 item
            DESC_1   TYPE CHAR40,             "Description vendor/GL 1 item
            MWSKZ_1  TYPE BSEG-MWSKZ,         "Tax code 1 item
           MWSTS1_1 TYPE BSEG-MWSTS,         "Tax Amount 1 item
            MWSTS2_1 TYPE BSEG-MWSTS,         "Amount is local currency 1 item
           MWSTS3_1 TYPE BSEG-MWSTS,         "Amount is foreign currency 1 item
            SGTXT_1  TYPE BSEG-SGTXT,         "Item text 1 item
            ZUONR_1  TYPE BSEG-ZUONR,         "Assignment 1 item
            BSCHL_2  TYPE BSEG-BSCHL,         "Posting key 2 item
            HKONT_2  TYPE BSEG-HKONT,         "Account 2 item
            DESC_2   TYPE CHAR40,             "Description vendor/GL 2 item
            MWSKZ_2  TYPE BSEG-MWSKZ,         "Tax code 2 item
           MWSTS1_2 TYPE BSEG-MWSTS,         "Tax Amount 2 item
            MWSTS2_2 TYPE BSEG-MWSTS,         "Amount is local currency 2 item
           MWSTS3_2 TYPE BSEG-MWSTS,         "Amount is foreign currency 2 item
            KOSTL    TYPE COBL-KOSTL,         "Cost center
            AUFNR    TYPE COBL-AUFNR,         "Internal order number
            SGTXT_2  TYPE BSEG-SGTXT,         "Item text 2 item
            ZUONR_2  TYPE BSEG-ZUONR,         "Assignment 2 item
          END OF TY_ERROR.
    ********************Data declaration***********************************
    DATA : T_DATA TYPE TABLE OF TY_DATA,   "Table to upload correct entries
           T_ERROR TYPE TABLE OF TY_ERROR. "Table to upload error data
    DATA : W_DATA TYPE TY_DATA,            "workarea for t_data
           W_ERROR TYPE TY_ERROR.          "workarea for t_error
    DATA : T_BDCDATA TYPE TABLE OF BDCDATA,
           W_BDCDATA TYPE BDCDATA.
    DATA : T_SEL_FILE TYPE FILETABLE,
           W_RETURN_CODE TYPE I VALUE '0',
           W_SEL_FILE LIKE LINE OF T_SEL_FILE.
    DATA : T_DATAIN TYPE TABLE OF TY_DATA,
           W_DATAIN TYPE string.
    DATA : W_FILE TYPE STRING.
    ********************At Selection Screen*********************************
    *selection screen validations
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
      CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
        EXPORTING
          WINDOW_TITLE            = 'Select File for upload'
       DEFAULT_EXTENSION       =
       DEFAULT_FILENAME        =
          FILE_FILTER             = '*.xls'
       WITH_ENCODING           =
       INITIAL_DIRECTORY       =
       MULTISELECTION          =
        CHANGING
          FILE_TABLE              = T_SEL_FILE
          RC                      = W_RETURN_CODE
       USER_ACTION             =
       FILE_ENCODING           =
        EXCEPTIONS
          FILE_OPEN_DIALOG_FAILED = 1
          CNTL_ERROR              = 2
          ERROR_NO_GUI            = 3
          NOT_SUPPORTED_BY_GUI    = 4
          OTHERS                  = 5
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                   WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      IF W_RETURN_CODE <> -1.
        READ TABLE T_SEL_FILE INTO W_SEL_FILE INDEX 1.
        CLEAR P_FILE.
        MOVE W_SEL_FILE TO P_FILE.
      ENDIF.
    *at selection screen
    AT SELECTION-SCREEN ON P_SESSN.
      IF P_SESSN IS INITIAL.
        P_SESSN = 'RECURRING'.
      ENDIF.
    AT SELECTION-SCREEN ON P_SESSN2.
      IF P_SESSN2 IS INITIAL.
        P_SESSN2 = 'RECURRING_E'.
      ENDIF.
    *********************Start of Selection ****************************
    START-OF-SELECTION.
      OPEN DATASET P_FILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    *error message when file not found.
      IF SY-SUBRC <> 0.
        MESSAGE 'File Not Found' TYPE 'E'.
      ENDIF.
      DO.
        READ DATASET P_FILE INTO w_datain.
        IF SY-SUBRC EQ 0.
          perform pre_process_record using w_datain
                                     changing w_data.
          PERFORM VALIDATE_DATA TABLES T_DATA
                                       T_ERROR
                                USING  W_DATA.
        ELSE.
          EXIT.
        ENDIF.
      ENDDO.
      CLOSE DATASET P_FILE.
    *check if any error has occured.
      IF T_ERROR[] IS NOT INITIAL.
        PERFORM FILL_BDC_TABLE TABLES T_ERROR
                                      T_BDCDATA
                               USING  P_SESSN2.
      ENDIF.
    *Check if any records are present to be uploaded.
      IF T_DATA[] IS NOT INITIAL.
        PERFORM FILL_BDC_TABLE TABLES T_DATA
                                      T_BDCDATA
                               USING  P_SESSN.
      ELSE.
        WRITE :/ 'No Correct Records were found to create session in SM35',
               / 'Please Check the File'.
      ENDIF.
    *&      Form  validate_data
          Sub routine to check correctness of the uploaded data.
         -->P_T_DATA  table to upload correct entries
         -->P_T_ERROR table to upload erroneous entries
         -->P_W_DATA  current record
    FORM VALIDATE_DATA  TABLES   P_T_DATA STRUCTURE  W_DATA
                                 P_T_ERROR STRUCTURE W_ERROR
                        USING    P_W_DATA.
      DATA : L_W_LIFNR TYPE LFA1-LIFNR,
             L_W_SAKNR TYPE SKA1-SAKNR.
      DATA:  L_W_DATA  TYPE TY_DATA,
             L_W_ERROR TYPE TY_ERROR.
      MOVE P_W_DATA TO L_W_DATA.
      DATA : L_FG_ERROR TYPE C,
             L_W_DATE   TYPE SY-DATUM.
      CONSTANTS : C_X       TYPE C VALUE 'X',
                  C_O2CA(4) TYPE C VALUE 'O2CA',
                  C_ZK_1(2) TYPE C VALUE 'ZK',
                  C_ZK_2(2) TYPE C VALUE 'zk',
                  C_NUM(17) TYPE C VALUE '01234567890/.-, ',
                  C_31(2)   TYPE C VALUE '31',
                  C_40(2)   TYPE C VALUE '40'.
      L_FG_ERROR = SPACE.
      DO.
    *check document type is 'ZK'
        IF NOT L_W_DATA-BLART NE C_ZK_1 OR
           L_W_DATA-BLART NE C_ZK_2.
          L_FG_ERROR = C_X.
          EXIT.
        ENDIF.
    *check 1 item text fields are filled by numeric value.
        IF NOT L_W_DATA-SGTXT_1 CO C_NUM.
          L_FG_ERROR = C_X.
          EXIT.
        ENDIF.
    *check 2 item text fields are filled by date.
        MOVE L_W_DATA-SGTXT_2 TO L_W_DATE.
        CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
          EXPORTING
            DATE                      = L_W_DATE
          EXCEPTIONS
            PLAUSIBILITY_CHECK_FAILED = 1
            OTHERS                    = 2.
        IF SY-SUBRC <> 0.
          L_FG_ERROR = C_X.
          EXIT.
        ENDIF.
    *check first posting key is '31'
        IF NOT L_W_DATA-BSCHL_1 EQ C_31.
          L_FG_ERROR = C_X.
          EXIT.
        ENDIF.
    *check second posting key is '40'
        IF NOT L_W_DATA-BSCHL_2 EQ C_40.
          L_FG_ERROR = C_X.
          EXIT.
        ENDIF.
    *check valid Vendor
        SELECT SINGLE LIFNR FROM LFA1 INTO L_W_LIFNR
                            WHERE LIFNR = L_W_DATA-HKONT_1.
        IF SY-SUBRC <> 0.
          L_FG_ERROR = C_X.
          EXIT.
        ENDIF.
    *check valid G/L account.
        SELECT SINGLE SAKNR FROM SKA1 INTO L_W_SAKNR
                            WHERE KTOPL = C_O2CA AND
                                  SAKNR = L_W_DATA-HKONT_2.
        IF SY-SUBRC <> 0.
          L_FG_ERROR = C_X.
          EXIT.
        ENDIF.
    *check 1 item assignment contains numeric value
        IF NOT L_W_DATA-ZUONR_1 CO C_NUM.
          L_FG_ERROR = C_X.
          EXIT.
        ENDIF.
    *check 2 item assigment contains date value
        MOVE L_W_DATA-ZUONR_2 TO L_W_DATE.
        CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
          EXPORTING
            DATE                      = L_W_DATE
          EXCEPTIONS
            PLAUSIBILITY_CHECK_FAILED = 1
            OTHERS                    = 2.
        IF SY-SUBRC <> 0.
          L_FG_ERROR = C_X.
          EXIT.
        ENDIF.
    *check if no error has occured
        IF NOT L_FG_ERROR EQ C_X.
          EXIT.
        ENDIF.
      ENDDO.
    *check error flag and insert error text.
      CASE L_FG_ERROR.
        WHEN C_X.                        "When error has occured.
          APPEND L_W_DATA TO P_T_ERROR.
        WHEN OTHERS.                     "When no error has occured.
          APPEND L_W_DATA TO P_T_DATA.
      ENDCASE.
    ENDFORM.                    " validate_data
    *&      Form  download_error_log
          Sub routine to download the error log
         -->P_T_ERROR  error log
    FORM DOWNLOAD_ERROR_LOG  TABLES   P_T_ERROR STRUCTURE W_ERROR.
      DATA : L_FILENAME TYPE STRING,
             L_PATH     TYPE STRING,
             L_FULLPATH TYPE STRING.
      CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
        EXPORTING
          WINDOW_TITLE         = 'Save the Error log'
        CHANGING
          FILENAME             = L_FILENAME
          PATH                 = L_PATH
          FULLPATH             = L_FULLPATH
        EXCEPTIONS
          CNTL_ERROR           = 1
          ERROR_NO_GUI         = 2
          NOT_SUPPORTED_BY_GUI = 3
          OTHERS               = 4.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CHECK L_FULLPATH IS NOT INITIAL.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          FILENAME                = L_FULLPATH
          FILETYPE                = 'ASC'
          WRITE_FIELD_SEPARATOR   = 'X'
        TABLES
          DATA_TAB                = P_T_ERROR
        EXCEPTIONS
          FILE_WRITE_ERROR        = 1
          NO_BATCH                = 2
          GUI_REFUSE_FILETRANSFER = 3
          INVALID_TYPE            = 4
          NO_AUTHORITY            = 5
          UNKNOWN_ERROR           = 6
          HEADER_NOT_ALLOWED      = 7
          SEPARATOR_NOT_ALLOWED   = 8
          FILESIZE_NOT_ALLOWED    = 9
          HEADER_TOO_LONG         = 10
          DP_ERROR_CREATE         = 11
          DP_ERROR_SEND           = 12
          DP_ERROR_WRITE          = 13
          UNKNOWN_DP_ERROR        = 14
          ACCESS_DENIED           = 15
          DP_OUT_OF_MEMORY        = 16
          DISK_FULL               = 17
          DP_TIMEOUT              = 18
          FILE_NOT_FOUND          = 19
          DATAPROVIDER_EXCEPTION  = 20
          CONTROL_FLUSH_ERROR     = 21
          OTHERS                  = 22.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " download_error_log
    *&      Form  fill_bdc_table
          bdc session is created in SM35
         -->P_T_DATA     correct data
         -->P_T_BDCDATA  bdcdata
         -->P_P_SESSN    session name
    FORM FILL_BDC_TABLE  TABLES   P_T_DATA STRUCTURE W_DATA
                                  P_T_BDCDATA STRUCTURE BDCDATA
                         USING    P_P_SESSN.
      DATA : L_W_DATA TYPE TY_DATA.    "workarea for t_data
      CONSTANTS: C_EUR(3) TYPE C VALUE 'EUR'.
    *open batch
      PERFORM OPEN_GROUP USING P_P_SESSN.
      LOOP AT P_T_DATA INTO L_W_DATA.
    *clear the bdc table
        REFRESH P_T_BDCDATA.
    *initial screen
        PERFORM BDC_DYNPRO TABLES P_T_BDCDATA
                           USING  'SAPMF05A' '0106'.
        PERFORM : BDC_FIELD TABLES P_T_BDCDATA USING 'BDC_CURSOR' 'BKPF-WAERS',
                  BDC_FIELD TABLES P_T_BDCDATA USING 'BDC_OKCODE' '/00',            "enter
                  BDC_FIELD TABLES P_T_BDCDATA USING 'BKPF-BUKRS' L_W_DATA-BUKRS,   "company code
                  BDC_FIELD TABLES P_T_BDCDATA USING 'BKDF-DBBDT' L_W_DATA-DBBDT,   "first run on
                  BDC_FIELD TABLES P_T_BDCDATA USING 'BKDF-DBATR' L_W_DATA-DBATR,   "next run on
                  BDC_FIELD TABLES P_T_BDCDATA USING 'BKDF-DBEDT' L_W_DATA-DBEDT,   "last run on
                  BDC_FIELD TABLES P_T_BDCDATA USING 'BKDF-DBMON' L_W_DATA-DBMON,   "run frequency
                  BDC_FIELD TABLES P_T_BDCDATA USING 'BKDF-DBTAG' L_W_DATA-DBTAG,   "run date
                  BDC_FIELD TABLES P_T_BDCDATA USING 'BKPF-BLART' L_W_DATA-BLART,   "document type
                  BDC_FIELD TABLES P_T_BDCDATA USING 'BKPF-WAERS' C_EUR,            "currency
                  BDC_FIELD TABLES P_T_BDCDATA USING 'BKPF-XBLNR' L_W_DATA-XBLNR,   "reference
                  BDC_FIELD TABLES P_T_BDCDATA USING 'BKPF-BKTXT' L_W_DATA-BKTXT,   "document header data
                  BDC_FIELD TABLES P_T_BDCDATA USING 'RF05A-NEWBS' L_W_DATA-BSCHL_1,"posting key
                  BDC_FIELD TABLES P_T_BDCDATA USING 'RF05A-NEWKO' L_W_DATA-HKONT_1."account no
    *second screen (First line item)
        PERFORM BDC_DYNPRO TABLES P_T_BDCDATA
                           USING 'SAPMF05A' '0302'.
        PERFORM : BDC_FIELD TABLES P_T_BDCDATA USING 'BDC_CURSOR' 'RF05A-NEWKO',
                  BDC_FIELD TABLES P_T_BDCDATA USING 'BDC_OKCODE' '/00',              "enter
                  BDC_FIELD TABLES P_T_BDCDATA USING 'BSEG-WRBTR' L_W_DATA-MWSTS2_1,  "amount in LC
                  BDC_FIELD TABLES P_T_BDCDATA USING 'BSEG-MWSKZ' L_W_DATA-MWSKZ_1,   "tax code
                  BDC_FIELD TABLES P_T_BDCDATA USING 'BSEG-ZUONR' L_W_DATA-ZUONR_1,   "assignment
                  BDC_FIELD TABLES P_T_BDCDATA USING 'BSEG-SGTXT' L_W_DATA-SGTXT_1,   "item level text
                  BDC_FIELD TABLES P_T_BDCDATA USING 'RF05A-NEWBS' L_W_DATA-BSCHL_2,  "posting key
                  BDC_FIELD TABLES P_T_BDCDATA USING 'RF05A-NEWKO' L_W_DATA-HKONT_2.  "account no
    *third screen (Second line item)
        PERFORM BDC_DYNPRO TABLES P_T_BDCDATA
                           USING 'SAPMF05A' '0300'.
        PERFORM : BDC_FIELD TABLES P_T_BDCDATA USING 'BDC_CURSOR' 'BSEG-EBELN',
                  BDC_FIELD TABLES P_T_BDCDATA USING 'BDC_OKCODE' '=AB',              "overview button
                  BDC_FIELD TABLES P_T_BDCDATA USING 'BSEG-WRBTR' L_W_DATA-MWSTS2_2,  "amount in LC
                  BDC_FIELD TABLES P_T_BDCDATA USING 'BSEG-MWSKZ' L_W_DATA-MWSKZ_2,   "tax code
                  BDC_FIELD TABLES P_T_BDCDATA USING 'BSEG-ZUONR' L_W_DATA-ZUONR_2,   "assigment
                  BDC_FIELD TABLES P_T_BDCDATA USING 'BSEG-SGTXT' L_W_DATA-SGTXT_2.   "item text
    *fourth screen (pop up)
        PERFORM BDC_DYNPRO TABLES P_T_BDCDATA
                           USING 'SAPLKACB' '0002'.
        PERFORM : BDC_FIELD TABLES P_T_BDCDATA USING 'BDC_CURSOR' 'COBL-KOSTL',
                  BDC_FIELD TABLES P_T_BDCDATA USING 'BDC_OKCODE' '=ENTE',            "ok button
                  BDC_FIELD TABLES P_T_BDCDATA USING 'COBL-KOSTL' L_W_DATA-KOSTL,     "cost center
                  BDC_FIELD TABLES P_T_BDCDATA USING 'COBL-AUFNR' L_W_DATA-AUFNR.     "order number
    *fifth screen
        PERFORM BDC_FIELD TABLES P_T_BDCDATA
                          USING 'SAPMF05A' '0070'.
        PERFORM : BDC_FIELD TABLES P_T_BDCDATA USING 'BDC_CURSOR' 'RF05A-NEWBS',
                  BDC_FIELD TABLES P_T_BDCDATA USING 'BDC_OKCODE' '=BU'.              "save document
        PERFORM BDC_INSERT TABLES P_T_BDCDATA
                            USING 'ZREC_ENTRY'.
      ENDLOOP.
    *close the batch.
      PERFORM CLOSE_GROUP.
    ENDFORM.                    " fill_bdc_table
    *&      Form  bdc_dynpro
          bdc screen insert sub routine
         -->P_T_BDCDATA  BDC table
         -->P_PROGRAM    Program name
         -->P_SCREEN     Screen no
    FORM BDC_DYNPRO  TABLES   P_T_BDCDATA STRUCTURE BDCDATA
                     USING    VALUE(P_PROGRAM)
                              VALUE(P_SCREEN).
      CONSTANTS C_X TYPE C VALUE 'X'.
      DATA L_W_BDCDATA TYPE BDCDATA.
      L_W_BDCDATA-PROGRAM = P_PROGRAM.
      L_W_BDCDATA-DYNPRO = P_SCREEN.
      L_W_BDCDATA-DYNBEGIN = C_X.
      APPEND L_W_BDCDATA TO P_T_BDCDATA.
    ENDFORM.                    " bdc_dynpro
    *&      Form  bdc_field
          bdc field screen routine
         -->P_T_BDCDATA  BDC table
         -->P_FIELD    Field name
         -->P_VALUE      Value
    FORM BDC_FIELD  TABLES   P_T_BDCDATA STRUCTURE BDCDATA
                    USING    VALUE(P_FIELD)
                             VALUE(P_VALUE).
      DATA L_W_BDCDATA TYPE BDCDATA.     "Work area
      L_W_BDCDATA-FNAM = P_FIELD.
      L_W_BDCDATA-FVAL = P_VALUE.
      APPEND L_W_BDCDATA TO P_T_BDCDATA.
    ENDFORM.                    " bdc_field
    *&      Form  open_group
          bdc  open group in sm35
         -->P_P_SESSN  session name
    FORM OPEN_GROUP  USING    P_P_SESSN.
      CONSTANTS C_X TYPE C VALUE 'X'.
      CALL FUNCTION 'BDC_OPEN_GROUP'
        EXPORTING
          CLIENT              = SY-MANDT
          GROUP               = P_P_SESSN
          KEEP                = C_X
          USER                = SY-UNAME
          PROG                = SY-CPROG
        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 ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " open_group
    *&      Form  bdc_insert
          bdc insert in sm35
         -->P_T_BDCDATA  bdcdata table
         -->P_tcode      transaction
    FORM BDC_INSERT  TABLES   P_T_BDCDATA STRUCTURE BDCDATA
                     USING    VALUE(P_TCODE).
      CALL FUNCTION 'BDC_INSERT'
        EXPORTING
          TCODE            = P_TCODE
        TABLES
          DYNPROTAB        = P_T_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 ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " bdc_insert
    *&      Form  close_group
          bdc close group in sm35
    FORM CLOSE_GROUP .
      CALL FUNCTION 'BDC_CLOSE_GROUP'
        EXCEPTIONS
          NOT_OPEN    = 1
          QUEUE_ERROR = 2
          OTHERS      = 3.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " close_group
    *&      Form  pre_process_record
          text
         -->P_W_DATAIN  text
         <--P_W_DATA  text
    FORM pre_process_record  USING    P_W_DATAIN
                             CHANGING P_W_DATA.
    move p_w_datain to p_w_data-bukrs.
    ENDFORM.                    " pre_process_record

    copy paste this code
    *& Report ZTEST_RECUPLOAD
    REPORT ZTEST_RECUPLOAD.
    *include bdcrecx1.
    *******************Selection screen*************************************
    SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME TITLE TEXT-T01 .
    PARAMETERS P_FILE TYPE RLGRAP-FILENAME OBLIGATORY.
    PARAMETERS P_SESSN TYPE APQI-GROUPID DEFAULT 'RECURRING'.
    PARAMETERS P_SESSN2 TYPE APQI-GROUPID DEFAULT 'RECURRING_E'.
    SELECTION-SCREEN END OF BLOCK 1.
    *********************Type declaration***********************************
    *type for data input table
    TYPES : BEGIN OF TY_DATA,
    BUKRS TYPE T001-BUKRS, "Company code
    BLART TYPE BKPF-BLART, "Document type
    * BUDAT TYPE BKPF-BUDAT, "Posting date
    DBBDT TYPE BKDF-DBBDT, "First run
    DBATR TYPE BKDF-DBATR, "Next run
    DBEDT TYPE BKDF-DBEDT, "last run
    DBMON TYPE BKDF-DBMON, "Run frequency
    DBTAG TYPE BKDF-DBTAG, "Run date
    * DBZHL TYPE BKDF-DBZHL, "no of runs
    XBLNR TYPE BKPF-XBLNR, "reference(site)
    BKTXT TYPE BKPF-BKTXT, "document header data
    * USNAM TYPE BKPF-USNAM, "User name
    * CPUDT TYPE BKPF-CPUDT, "Entry date
    BSCHL_1 TYPE BSEG-BSCHL, "Posting key 1 item
    HKONT_1 TYPE BSEG-HKONT, "Account 1 item
    DESC_1 TYPE CHAR40, "Description vendor/GL 1 item
    MWSKZ_1 TYPE BSEG-MWSKZ, "Tax code 1 item
    * MWSTS1_1 TYPE BSEG-MWSTS, "Tax Amount 1 item
    MWSTS2_1 TYPE BSEG-MWSTS, "Amount is local currency 1 item
    * MWSTS3_1 TYPE BSEG-MWSTS, "Amount is foreign currency 1 item
    SGTXT_1 TYPE BSEG-SGTXT, "Item text 1 item
    ZUONR_1 TYPE BSEG-ZUONR, "Assignment 1 item
    BSCHL_2 TYPE BSEG-BSCHL, "Posting key 2 item
    HKONT_2 TYPE BSEG-HKONT, "Account 2 item
    DESC_2 TYPE CHAR40, "Description vendor/GL 2 item
    MWSKZ_2 TYPE BSEG-MWSKZ, "Tax code 2 item
    ** MWSTS1_2 TYPE BSEG-MWSTS, "Tax Amount 2 item
    MWSTS2_2 TYPE BSEG-MWSTS, "Amount is local currency 2 item
    * MWSTS3_2 TYPE BSEG-MWSTS, "Amount is foreign currency 2 item
    KOSTL TYPE COBL-KOSTL, "Cost center
    AUFNR TYPE COBL-AUFNR, "Internal order number
    SGTXT_2 TYPE BSEG-SGTXT, "Item text 2 item
    ZUONR_2 TYPE BSEG-ZUONR, "Assignment 2 item
    END OF TY_DATA.
    *type for data error table
    TYPES : BEGIN OF TY_ERROR,
    BUKRS TYPE T001-BUKRS, "Company code
    BLART TYPE BKPF-BLART, "Document type
    * BUDAT TYPE BKPF-BUDAT, "Posting date
    DBBDT TYPE BKDF-DBBDT, "First run
    DBATR TYPE BKDF-DBATR, "Next run
    DBEDT TYPE BKDF-DBEDT, "last run
    DBMON TYPE BKDF-DBMON, "Run frequency
    DBTAG TYPE BKDF-DBTAG, "Run date
    * DBZHL TYPE BKDF-DBZHL, "no of runs
    XBLNR TYPE BKPF-XBLNR, "reference(site)
    BKTXT TYPE BKPF-BKTXT, "document header data
    * USNAM TYPE BKPF-USNAM, "User name
    * CPUDT TYPE BKPF-CPUDT, "Entry date
    BSCHL_1 TYPE BSEG-BSCHL, "Posting key 1 item
    HKONT_1 TYPE BSEG-HKONT, "Account 1 item
    DESC_1 TYPE CHAR40, "Description vendor/GL 1 item
    MWSKZ_1 TYPE BSEG-MWSKZ, "Tax code 1 item
    * MWSTS1_1 TYPE BSEG-MWSTS, "Tax Amount 1 item
    MWSTS2_1 TYPE BSEG-MWSTS, "Amount is local currency 1 item
    * MWSTS3_1 TYPE BSEG-MWSTS, "Amount is foreign currency 1 item
    SGTXT_1 TYPE BSEG-SGTXT, "Item text 1 item
    ZUONR_1 TYPE BSEG-ZUONR, "Assignment 1 item
    BSCHL_2 TYPE BSEG-BSCHL, "Posting key 2 item
    HKONT_2 TYPE BSEG-HKONT, "Account 2 item
    DESC_2 TYPE CHAR40, "Description vendor/GL 2 item
    MWSKZ_2 TYPE BSEG-MWSKZ, "Tax code 2 item
    * MWSTS1_2 TYPE BSEG-MWSTS, "Tax Amount 2 item
    MWSTS2_2 TYPE BSEG-MWSTS, "Amount is local currency 2 item
    * MWSTS3_2 TYPE BSEG-MWSTS, "Amount is foreign currency 2 item
    KOSTL TYPE COBL-KOSTL, "Cost center
    AUFNR TYPE COBL-AUFNR, "Internal order number
    SGTXT_2 TYPE BSEG-SGTXT, "Item text 2 item
    ZUONR_2 TYPE BSEG-ZUONR, "Assignment 2 item
    END OF TY_ERROR.
    *********************Data declaration************************************
    DATA : T_DATA TYPE TABLE OF TY_DATA, "Table to upload correct entries
    T_ERROR TYPE TABLE OF TY_ERROR. "Table to upload error data
    DATA : W_DATA type TY_DATA, "workarea for t_data
    W_ERROR TYPE TY_ERROR. "workarea for t_error
    DATA : T_BDCDATA TYPE TABLE OF BDCDATA,
    W_BDCDATA TYPE BDCDATA.
    DATA : T_SEL_FILE TYPE FILETABLE,
    W_RETURN_CODE TYPE I VALUE '0',
    W_SEL_FILE LIKE LINE OF T_SEL_FILE.
    DATA : T_DATAIN TYPE TABLE OF TY_DATA,
    W_DATAIN TYPE string.
    DATA : W_FILE TYPE STRING.
    *********************At Selection Screen**********************************
    *selection screen validations
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
    EXPORTING
    WINDOW_TITLE = 'Select File for upload'
    * DEFAULT_EXTENSION =
    * DEFAULT_FILENAME =
    FILE_FILTER = '*.xls'
    * WITH_ENCODING =
    * INITIAL_DIRECTORY =
    * MULTISELECTION =
    CHANGING
    FILE_TABLE = T_SEL_FILE
    RC = W_RETURN_CODE
    * USER_ACTION =
    * FILE_ENCODING =
    EXCEPTIONS
    FILE_OPEN_DIALOG_FAILED = 1
    CNTL_ERROR = 2
    ERROR_NO_GUI = 3
    NOT_SUPPORTED_BY_GUI = 4
    OTHERS = 5
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    IF W_RETURN_CODE <> -1.
    READ TABLE T_SEL_FILE INTO W_SEL_FILE INDEX 1.
    CLEAR P_FILE.
    MOVE W_SEL_FILE TO P_FILE.
    ENDIF.
    *at selection screen
    AT SELECTION-SCREEN ON P_SESSN.
    IF P_SESSN IS INITIAL.
    P_SESSN = 'RECURRING'.
    ENDIF.
    AT SELECTION-SCREEN ON P_SESSN2.
    IF P_SESSN2 IS INITIAL.
    P_SESSN2 = 'RECURRING_E'.
    ENDIF.
    *********************Start of Selection ****************************
    START-OF-SELECTION.
    OPEN DATASET P_FILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    *error message when file not found.
    IF SY-SUBRC <> 0.
    MESSAGE 'File Not Found' TYPE 'E'.
    ENDIF.
    DO.
    READ DATASET P_FILE INTO w_datain.
    IF SY-SUBRC EQ 0.
    perform pre_process_record using w_datain
    changing w_data.
    PERFORM VALIDATE_DATA TABLES T_DATA
    T_ERROR
    USING W_DATA.
    ELSE.
    EXIT.
    ENDIF.
    ENDDO.
    CLOSE DATASET P_FILE.
    *check if any error has occured.
    IF T_ERROR[] IS NOT INITIAL.
    PERFORM FILL_BDC_TABLE TABLES T_ERROR
    T_BDCDATA
    USING P_SESSN2.
    ENDIF.
    *Check if any records are present to be uploaded.
    IF T_DATA[] IS NOT INITIAL.
    PERFORM FILL_BDC_TABLE TABLES T_DATA
    T_BDCDATA
    USING P_SESSN.
    ELSE.
    WRITE :/ 'No Correct Records were found to create session in SM35',
    / 'Please Check the File'.
    ENDIF.
    *& Form validate_data
    * Sub routine to check correctness of the uploaded data.
    * -->P_T_DATA table to upload correct entries
    * -->P_T_ERROR table to upload erroneous entries
    * -->P_W_DATA current record
    FORM VALIDATE_DATA TABLES P_T_DATA STRUCTURE W_DATA
    P_T_ERROR STRUCTURE W_ERROR
    USING P_W_DATA structure w_data .
    DATA : L_W_LIFNR TYPE LFA1-LIFNR,
    L_W_SAKNR TYPE SKA1-SAKNR.
    DATA: L_W_DATA TYPE TY_DATA,
    L_W_ERROR TYPE TY_ERROR.
    MOVE P_W_DATA TO L_W_DATA.
    DATA : L_FG_ERROR TYPE C,
    L_W_DATE TYPE SY-DATUM.
    CONSTANTS : C_X TYPE C VALUE 'X',
    C_O2CA(4) TYPE C VALUE 'O2CA',
    C_ZK_1(2) TYPE C VALUE 'ZK',
    C_ZK_2(2) TYPE C VALUE 'zk',
    C_NUM(17) TYPE C VALUE '01234567890/.-, ',
    C_31(2) TYPE C VALUE '31',
    C_40(2) TYPE C VALUE '40'.
    L_FG_ERROR = SPACE.
    DO.
    *check document type is 'ZK'
    IF NOT L_W_DATA-BLART NE C_ZK_1 OR
    L_W_DATA-BLART NE C_ZK_2.
    L_FG_ERROR = C_X.
    EXIT.
    ENDIF.
    *check 1 item text fields are filled by numeric value.
    IF NOT L_W_DATA-SGTXT_1 CO C_NUM.
    L_FG_ERROR = C_X.
    EXIT.
    ENDIF.
    *check 2 item text fields are filled by date.
    MOVE L_W_DATA-SGTXT_2 TO L_W_DATE.
    CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
    EXPORTING
    DATE = L_W_DATE
    EXCEPTIONS
    PLAUSIBILITY_CHECK_FAILED = 1
    OTHERS = 2.
    IF SY-SUBRC <> 0.
    L_FG_ERROR = C_X.
    EXIT.
    ENDIF.
    *check first posting key is '31'
    IF NOT L_W_DATA-BSCHL_1 EQ C_31.
    L_FG_ERROR = C_X.
    EXIT.
    ENDIF.
    *check second posting key is '40'
    IF NOT L_W_DATA-BSCHL_2 EQ C_40.
    L_FG_ERROR = C_X.
    EXIT.
    ENDIF.
    *check valid Vendor
    SELECT SINGLE LIFNR FROM LFA1 INTO L_W_LIFNR
    WHERE LIFNR = L_W_DATA-HKONT_1.
    IF SY-SUBRC <> 0.
    L_FG_ERROR = C_X.
    EXIT.
    ENDIF.
    *check valid G/L account.
    SELECT SINGLE SAKNR FROM SKA1 INTO L_W_SAKNR
    WHERE KTOPL = C_O2CA AND
    SAKNR = L_W_DATA-HKONT_2.
    IF SY-SUBRC <> 0.
    L_FG_ERROR = C_X.
    EXIT.
    ENDIF.
    *check 1 item assignment contains numeric value
    IF NOT L_W_DATA-ZUONR_1 CO C_NUM.
    L_FG_ERROR = C_X.
    EXIT.
    ENDIF.
    *check 2 item assigment contains date value
    MOVE L_W_DATA-ZUONR_2 TO L_W_DATE.
    CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
    EXPORTING
    DATE = L_W_DATE
    EXCEPTIONS
    PLAUSIBILITY_CHECK_FAILED = 1
    OTHERS = 2.
    IF SY-SUBRC <> 0.
    L_FG_ERROR = C_X.
    EXIT.
    ENDIF.
    *check if no error has occured
    IF NOT L_FG_ERROR EQ C_X.
    EXIT.
    ENDIF.
    ENDDO.
    *check error flag and insert error text.
    CASE L_FG_ERROR.
    WHEN C_X. "When error has occured.
    APPEND L_W_DATA TO P_T_ERROR.
    WHEN OTHERS. "When no error has occured.
    APPEND L_W_DATA TO P_T_DATA.
    ENDCASE.
    ENDFORM. " validate_data
    *& Form download_error_log
    * Sub routine to download the error log
    * -->P_T_ERROR error log
    FORM DOWNLOAD_ERROR_LOG TABLES P_T_ERROR STRUCTURE W_ERROR.
    DATA : L_FILENAME TYPE STRING,
    L_PATH TYPE STRING,
    L_FULLPATH TYPE STRING.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
    EXPORTING
    WINDOW_TITLE = 'Save the Error log'
    CHANGING
    FILENAME = L_FILENAME
    PATH = L_PATH
    FULLPATH = L_FULLPATH
    EXCEPTIONS
    CNTL_ERROR = 1
    ERROR_NO_GUI = 2
    NOT_SUPPORTED_BY_GUI = 3
    OTHERS = 4.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CHECK L_FULLPATH IS NOT INITIAL.
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    FILENAME = L_FULLPATH
    FILETYPE = 'ASC'
    WRITE_FIELD_SEPARATOR = 'X'
    TABLES
    DATA_TAB = P_T_ERROR
    EXCEPTIONS
    FILE_WRITE_ERROR = 1
    NO_BATCH = 2
    GUI_REFUSE_FILETRANSFER = 3
    INVALID_TYPE = 4
    NO_AUTHORITY = 5
    UNKNOWN_ERROR = 6
    HEADER_NOT_ALLOWED = 7
    SEPARATOR_NOT_ALLOWED = 8
    FILESIZE_NOT_ALLOWED = 9
    HEADER_TOO_LONG = 10
    DP_ERROR_CREATE = 11
    DP_ERROR_SEND = 12
    DP_ERROR_WRITE = 13
    UNKNOWN_DP_ERROR = 14
    ACCESS_DENIED = 15
    DP_OUT_OF_MEMORY = 16
    DISK_FULL = 17
    DP_TIMEOUT = 18
    FILE_NOT_FOUND = 19
    DATAPROVIDER_EXCEPTION = 20
    CONTROL_FLUSH_ERROR = 21
    OTHERS = 22.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM. " download_error_log
    *& Form fill_bdc_table
    * bdc session is created in SM35
    * -->P_T_DATA correct data
    * -->P_T_BDCDATA bdcdata
    * -->P_P_SESSN session name
    FORM FILL_BDC_TABLE TABLES P_T_DATA STRUCTURE W_DATA
    P_T_BDCDATA STRUCTURE BDCDATA
    USING P_P_SESSN.
    DATA : L_W_DATA TYPE TY_DATA. "workarea for t_data
    CONSTANTS: C_EUR(3) TYPE C VALUE 'EUR'.
    *open batch
    PERFORM OPEN_GROUP USING P_P_SESSN.
    LOOP AT P_T_DATA INTO L_W_DATA.
    *clear the bdc table
    REFRESH P_T_BDCDATA.
    *initial screen
    PERFORM BDC_DYNPRO TABLES P_T_BDCDATA
    USING 'SAPMF05A' '0106'.
    PERFORM : BDC_FIELD TABLES P_T_BDCDATA USING 'BDC_CURSOR' 'BKPF-WAERS',
    BDC_FIELD TABLES P_T_BDCDATA USING 'BDC_OKCODE' '/00', "enter
    BDC_FIELD TABLES P_T_BDCDATA USING 'BKPF-BUKRS' L_W_DATA-BUKRS, "company code
    BDC_FIELD TABLES P_T_BDCDATA USING 'BKDF-DBBDT' L_W_DATA-DBBDT, "first run on
    BDC_FIELD TABLES P_T_BDCDATA USING 'BKDF-DBATR' L_W_DATA-DBATR, "next run on
    BDC_FIELD TABLES P_T_BDCDATA USING 'BKDF-DBEDT' L_W_DATA-DBEDT, "last run on
    BDC_FIELD TABLES P_T_BDCDATA USING 'BKDF-DBMON' L_W_DATA-DBMON, "run frequency
    BDC_FIELD TABLES P_T_BDCDATA USING 'BKDF-DBTAG' L_W_DATA-DBTAG, "run date
    BDC_FIELD TABLES P_T_BDCDATA USING 'BKPF-BLART' L_W_DATA-BLART, "document type
    BDC_FIELD TABLES P_T_BDCDATA USING 'BKPF-WAERS' C_EUR, "currency
    BDC_FIELD TABLES P_T_BDCDATA USING 'BKPF-XBLNR' L_W_DATA-XBLNR, "reference
    BDC_FIELD TABLES P_T_BDCDATA USING 'BKPF-BKTXT' L_W_DATA-BKTXT, "document header data
    BDC_FIELD TABLES P_T_BDCDATA USING 'RF05A-NEWBS' L_W_DATA-BSCHL_1,"posting key
    BDC_FIELD TABLES P_T_BDCDATA USING 'RF05A-NEWKO' L_W_DATA-HKONT_1."account no
    *second screen (First line item)
    PERFORM BDC_DYNPRO TABLES P_T_BDCDATA
    USING 'SAPMF05A' '0302'.
    PERFORM : BDC_FIELD TABLES P_T_BDCDATA USING 'BDC_CURSOR' 'RF05A-NEWKO',
    BDC_FIELD TABLES P_T_BDCDATA USING 'BDC_OKCODE' '/00', "enter
    BDC_FIELD TABLES P_T_BDCDATA USING 'BSEG-WRBTR' L_W_DATA-MWSTS2_1, "amount in LC
    BDC_FIELD TABLES P_T_BDCDATA USING 'BSEG-MWSKZ' L_W_DATA-MWSKZ_1, "tax code
    BDC_FIELD TABLES P_T_BDCDATA USING 'BSEG-ZUONR' L_W_DATA-ZUONR_1, "assignment
    BDC_FIELD TABLES P_T_BDCDATA USING 'BSEG-SGTXT' L_W_DATA-SGTXT_1, "item level text
    BDC_FIELD TABLES P_T_BDCDATA USING 'RF05A-NEWBS' L_W_DATA-BSCHL_2, "posting key
    BDC_FIELD TABLES P_T_BDCDATA USING 'RF05A-NEWKO' L_W_DATA-HKONT_2. "account no
    *third screen (Second line item)
    PERFORM BDC_DYNPRO TABLES P_T_BDCDATA
    USING 'SAPMF05A' '0300'.
    PERFORM : BDC_FIELD TABLES P_T_BDCDATA USING 'BDC_CURSOR' 'BSEG-EBELN',
    BDC_FIELD TABLES P_T_BDCDATA USING 'BDC_OKCODE' '=AB', "overview button
    BDC_FIELD TABLES P_T_BDCDATA USING 'BSEG-WRBTR' L_W_DATA-MWSTS2_2, "amount in LC
    BDC_FIELD TABLES P_T_BDCDATA USING 'BSEG-MWSKZ' L_W_DATA-MWSKZ_2, "tax code
    BDC_FIELD TABLES P_T_BDCDATA USING 'BSEG-ZUONR' L_W_DATA-ZUONR_2, "assigment
    BDC_FIELD TABLES P_T_BDCDATA USING 'BSEG-SGTXT' L_W_DATA-SGTXT_2. "item text
    *fourth screen (pop up)
    PERFORM BDC_DYNPRO TABLES P_T_BDCDATA
    USING 'SAPLKACB' '0002'.
    PERFORM : BDC_FIELD TABLES P_T_BDCDATA USING 'BDC_CURSOR' 'COBL-KOSTL',
    BDC_FIELD TABLES P_T_BDCDATA USING 'BDC_OKCODE' '=ENTE', "ok button
    BDC_FIELD TABLES P_T_BDCDATA USING 'COBL-KOSTL' L_W_DATA-KOSTL, "cost center
    BDC_FIELD TABLES P_T_BDCDATA USING 'COBL-AUFNR' L_W_DATA-AUFNR. "order number
    *fifth screen
    PERFORM BDC_FIELD TABLES P_T_BDCDATA
    USING 'SAPMF05A' '0070'.
    PERFORM : BDC_FIELD TABLES P_T_BDCDATA USING 'BDC_CURSOR' 'RF05A-NEWBS',
    BDC_FIELD TABLES P_T_BDCDATA USING 'BDC_OKCODE' '=BU'. "save document
    PERFORM BDC_INSERT TABLES P_T_BDCDATA
    USING 'ZREC_ENTRY'.
    ENDLOOP.
    *close the batch.
    PERFORM CLOSE_GROUP.
    ENDFORM. " fill_bdc_table
    *& Form bdc_dynpro
    * bdc screen insert sub routine
    * -->P_T_BDCDATA BDC table
    * -->P_PROGRAM Program name
    * -->P_SCREEN Screen no
    FORM BDC_DYNPRO TABLES P_T_BDCDATA STRUCTURE BDCDATA
    USING VALUE(P_PROGRAM)
    VALUE(P_SCREEN).
    CONSTANTS C_X TYPE C VALUE 'X'.
    DATA L_W_BDCDATA TYPE BDCDATA.
    L_W_BDCDATA-PROGRAM = P_PROGRAM.
    L_W_BDCDATA-DYNPRO = P_SCREEN.
    L_W_BDCDATA-DYNBEGIN = C_X.
    APPEND L_W_BDCDATA TO P_T_BDCDATA.
    ENDFORM. " bdc_dynpro
    *& Form bdc_field
    * bdc field screen routine
    * -->P_T_BDCDATA BDC table
    * -->P_FIELD Field name
    * -->P_VALUE Value
    FORM BDC_FIELD TABLES P_T_BDCDATA STRUCTURE BDCDATA
    USING VALUE(P_FIELD)
    VALUE(P_VALUE).
    DATA L_W_BDCDATA TYPE BDCDATA. "Work area
    L_W_BDCDATA-FNAM = P_FIELD.
    L_W_BDCDATA-FVAL = P_VALUE.
    APPEND L_W_BDCDATA TO P_T_BDCDATA.
    ENDFORM. " bdc_field
    *& Form open_group
    * bdc open group in sm35
    * -->P_P_SESSN session name
    FORM OPEN_GROUP USING P_P_SESSN.
    CONSTANTS C_X TYPE C VALUE 'X'.
    CALL FUNCTION 'BDC_OPEN_GROUP'
    EXPORTING
    CLIENT = SY-MANDT
    GROUP = P_P_SESSN
    KEEP = C_X
    USER = SY-UNAME
    PROG = SY-CPROG
    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 ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM. " open_group
    *& Form bdc_insert
    * bdc insert in sm35
    * -->P_T_BDCDATA bdcdata table
    * -->P_tcode transaction
    FORM BDC_INSERT TABLES P_T_BDCDATA STRUCTURE BDCDATA
    USING VALUE(P_TCODE).
    CALL FUNCTION 'BDC_INSERT'
    EXPORTING
    TCODE = P_TCODE
    TABLES
    DYNPROTAB = P_T_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 ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM. " bdc_insert
    *& Form close_group
    * bdc close group in sm35
    FORM CLOSE_GROUP .
    CALL FUNCTION 'BDC_CLOSE_GROUP'
    EXCEPTIONS
    NOT_OPEN = 1
    QUEUE_ERROR = 2
    OTHERS = 3.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM. " close_group
    *& Form pre_process_record
    * text
    * -->P_W_DATAIN text
    * <--P_W_DATA text
    FORM pre_process_record USING P_W_DATAIN
    CHANGING P_W_DATA structure w_data.
    move p_w_datain to p_w_data-bukrs.
    ENDFORM. " pre_process_record

  • Syntax Error in Routine while Activating Transformation

    Dear All,
    I am activating whole scenario for 0SD_C03. we have made transformation for 2lis_11_vaitm, during installation we get below errors:
    - Rule (target: 0SUBTOT_1S, group: 01 Standard Group): Syntax error in routine
    -Rule (target: 0NET_VAL_S, group: 01 Standard Group): Syntax error in routine
    -Rule (target: 0PROD_CATEG, group: 01 Standard Group): Syntax error in routine
    I really appreciate your any input for this.
    Thanks & Regards,
    Darshan

    Hi,
    I hope there is inbalance in between SOURCE Datapackage and Target Datapackage. So in the start routines pls check it and it not found then add in DATA_PACKAGE...
    Check with ABAPer
    under ,
    TYPES:
          BEGIN OF tys_TG_1_full,
            SUBTOT_1S           TYPE /BI0/OISUBTOT_1S,
    and also you can fin dsimilar kind of threads in SDN.
    Re: Syntax Error in Routine while Activating Transformation
    Re: Issue while creating Transformation from Update rule.
    Re: 0IC_C03 activation of Transformation rule ends with ERROR
    Re: Error in activation of transformation
    Thanks
    Reddy

  • Data Source 0HR_PA_0 Syntax Error in the start routine while activating

    Hi All,
    I have migrated the Business content for the data source 0HR_PA_0
    While activating the transformation-2 there is errors like:
    Start Routine: Syntax error in routine
    Rule (target: 0HDCNT_LAST, group: 01 Standard Group): Syntax error in routine
    Rule (target: 0AGE_KYF, group: 01 Standard Group): Syntax error in routine
    .................... etc
    I need help to resolve this issue.
    Thanks & Regards,
    Savitha

    Hello Jurgita,
    When Data Source was migrated the codes related to COMM_STRUCTURE was missing in the start routinue.
    Following codes (in bold) with regard to COMM_STRUCTURE added and then got activated
    4.     *--
    5.         COMM_STRUCTURE   type tys_sc_1__rule_25,
    6.         l_subrc          type sy-tabix,
    7.         l_abort          type sy-tabix,
    8.         ls_monitor       TYPE rsmonitor,
    9.         ls_monitor_recno TYPE rsmonitors.
    10.     
    11.       REFRESH:
    12.         MONITOR.
    13.     
    14.     * Runtime attributs
    15.         SOURCE_SYSTEM  = p_r_request->get_logsys( ).
    16.         move-corresponding SOURCE_FIELDS to COMM_STRUCTURE.
    17.     
    18.     *  Migrated update rule call
    19.       Perform routine_0011
    20.       using
    21.         COMM_STRUCTURE
    22.       CHANGING
    Regards,
    Savitha
    Edited by: Savitha  Ravi on Jun 19, 2009 6:34 AM

  • The Web Dynpro component cannot be generated due to serious (syntax) errors

    Hi everybody,
    While I was developing a web dynpro application, I had an error but I couldn't understand this error. Before I took this error message, only I changed bound one context node to another context node in a RadioButtonGroupByKey.Therefore, when I pushed activate button, I took an error message.This error message said "The Web Dynpro component cannot be generated due to serious (syntax) errors". What does it mean ? How can I find out where is the error in the application. Also, I think the reason of this error message is about a BC problem. I am waiting for your comment urgently.

    Hi ,
    Just delete the context (by using the context binding) and bind the field with the correct node and try to activate .
    One more suggestion is that after deleting the binding and before binding to other node check it that whether that binding was properly deleted or not.Some times its not deleting the binding.
    Hopely my suggestion may work.
    Regards,
    Satya

  • Syntax error  while executing Key Figure routine

    Hello,
    I am posting my question again, as I have not got any solution. Please help it will be really appreciated. Here's the description
    I am loading data from flatfile to an Infocube with 3 keyfigures: Sales Price , Sales Quantity, Sales Revune. Getting values for Sales Price and Salea Quantity  from flatfile and calculating for Sales Revunue IO_VB_REV using routine
    - I created Transformations, and under Rule Group: Standard Group box I have not mapped IO_VB_REV  any datasource field and see 'X' sign against the field.
    - In rules detail screen, I add two source fields of Rule , IO_VB_QU and IO_VB_PRC. I see IO_VB_REV already added under 'Target fields of Rule' section
    - I then add the only following line to routine
    RESULT = SOURCE_FIELDS_RULE-/BIC/IO_VB_QU * SOURCE_FIELDS_RULE-/BIC/IO_VB_PRC .
    - Clicking on check button it gives no syntax error message. I save and exit back to Rule Details page.
    - For IO_VB_REV field If I select any of 2 options i.e. Fixed Unit or No conversion it gives me a dump. So I select 'from conversion' option. In that case I enter USD against 'Conversion Type' field. It gives me information box popup with 'Incorrect Input Message'
    - When check button hit on 'Rule Details' page, it gives me error message ' Syntax error in routine '
    Why is it giving me syntax error, inspite of the fact that I get 'no syntax error' message on routine page. Also why am I getting short dumps on changing Conversion Type

    Hi Olivier,
    I really thank you for ur efforts in helping me solving this problem. Below is complete description of KF defined,
    1. Created InfoObjects for Sales Quantity, Sales Price, Sales Revunue
    Definition of <b>Sales Quantity</b>
    Name: IO_VB_QU
    Type/Data Type : Quantity
    Data Type: QUAN - Quantity field, points to unit field with format UN
    Currency / unit of measure
    Unit / Currency: 0UNIT
    Definition of <b>Sales Price</b>
    Name: IO_VB_PRC
    Type/Data Type : Amount
    Data Type: CURR - Currency field, stored as DEC
    Currency / unit of measure
    Fixed Currency: USD
    Definition of <b>Sales Revunue</b>
    Name: IO_VB_REV
    Type/Data Type : Amount
    Data Type: CURR - Currency field, stored as DEC
    Currency / unit of measure
    Fixed Currency: USD
    2. As the data is being read from flatfile, created DataSource with fields for Sales ID, Sales Price, Sales Quantity. As I am reading unit for quantity from file (has values EA,BOX,CSE), I have a corresponding field UNIT in DataSource. No field for Sales Revunue.
    3. I use 'Create Transformation' functionality to automatically create transformations.
    4. Rule Details page of each of 3 KFs has following values
    <b>Rule Details page of Sales Quantity</b>
    Rule Type: Direct Assignment
    Aggregation : Summation
    Target Unit: 0UNIT
    Unit: from Source
    Source Unit: UNIT
    Source Fields of Rule: /BIC/IO_VB_QU, UNIT
    Target Fields of Rule: 0UNIT, IO_VB_QU
    <b>Rule Details page of Sales Price</b>
    Rule Type: Direct Assignment
    Aggregation : Maximum
    Fixed Target Currency : USD
    Currency: No Conversion
    Source Fields of Rule: /BIC/IO_VB_PRC
    Target Fields of Rule:  IO_VB_PRC
    <b>Rule Details page of Sales Revunue</b>
    Rule Type: Routine   
    Aggregation : Summation
    Fixed Target Currency : USD
    Currency: from Conversion
    Conversion Type: ??????.....(I entered USD it gives me Incorrect Input message)
    Source Fields of Rule: /BIC/IO_VB_PRC, /BIC/IO_VB_QU, UNIT
    Target Fields of Rule:  IO_VB_REV
    I have this line is the routine 
    RESULT = SOURCE_FIELDS_RULE-/BIC/IO_VB_QU *   SOURCE_FIELDS_RULE-/BIC/IO_VB_PRC.
    Let me know if u need any other info......
    I really appreciate u trying  to help me
    Vidya

  • Getting syntax error while executing keyfigure routine BI 7.0

    Hello,
    I am writing a very simple keyfigure routine to calculate sales revune using sales quantity and sales price, I am getting error as follows
    - I am in 'Rules Details' screen and I have selected 'Routine' as the rule type. I enter the following code in routine
         RESULT = SOURCE_FIELDS_RULE-/BIC/IO_VB_QU *
         SOURCE_FIELDS_RULE-/BIC/IO_VB_PRC .
    - I hit the check button on the routine page, it says no syntax errors
    - Now I am back in the 'Rules Details' page and I hit the 'Check' button it gives me the following error
    Rule(target IO_VB_REV, group: Standard Group): Syntax error in routine
    Please tell me what is wrong. what should i check

    Hi Vaibhav,
    Here are the details
    - I am loading data from flatfile to an Infocube with 3 keyfigures: IO_VB_PRC (Sales Price) , IO_VB_QU (Sales Quantity), IO_VB_REV (Sales Revune). Getting values for IO_VB_QU and IO_Vb_PRC from flatfile and calculating for IO_VB_REV using routine
    - I created Transformations, and under  Rule Group: Standard Group box I see 'X' sign against 'IO_VB_REV' field, meaning not mapped to any datasource field
    - In rules detail screen, I add two source fields of Rule , IO_VB_QU and IO_VB_PRC. I see IO_VB_REV already added under 'Target fields of Rule' section
    - I then add the only following line to routine
    RESULT = SOURCE_FIELDS_RULE-/BIC/IO_VB_QU *    SOURCE_FIELDS_RULE-/BIC/IO_VB_PRC .
    Clicking on check button it gives no syntax error message. I save and exit back to Rule Details page.
    - I specify 'USD' as the Conversion Type and then click on check button it initially gives me 'Incorrect Input'  written in an information message box and then error that Syntax error in routine
    Let me know what is that I am missing
    Thanks for helping

Maybe you are looking for