Exception Internal_error in smartform

Dear Gurus,
I designed a  Custom smartform and a driver program also.
When I tried to execute my driver program. It's showing an error that Line type %LTYPE2 is unknown.
Also I tried to execute my smartform individually by execute the FM. Then it's throwing some exception as INTERNAL_ERROR.
Could you help me out by saying what would be reason for this exception and issue.
Thanks
Natasha SS

I guess ,the problem is with the table that you have created inside your smartform.
It can be bacause of the following.
1) Check the table which has Line tyoe "%LTYPE2 " and make sure the total width is equal to the window width.
2) Make sure same line type is  "%LTYPE2 "  has enough columns to show data
   Example: Let us assume your "%LTYPE2 " can display only 3 columns
   In text element, under output Option (tab) below your table you might have choosen,
below Output Table..
  Check box active with New Line  "%LTYPE2 "
  and for second text element you might have choosen
below Output Table..
  Check new Cell with '0" skip cells. <-- make sure it is Zero, if it is 2 or more that means, you are expecting it to print in 4th column but line type has max of 3 columns. So, it can give you an error. (in your case, if it is Zero then check the below steps)
  and for Third text element you might have choosen
below Output Table..
  Check new Cell with '0" skip cells. <-- make sure it is Zero, if it is 1 or more that means, you are expecting it to print in 4th column but line type has max of 3 columns. So, it can give you an error. (in your case, if it is Zero then check the below steps)
  and for fourth text element you might have choosen
below Output Table..
  Check new Cell with '0" skip cells. <-- It give the error message as your line type can hold only max of 3 columns.
3) also check the your two conditions are true and trying to print in the same column.
The error can be bacause of any of the above scenarios.
I guess, the above info will help you to solve your issue.
Regards,
SaiRam

Similar Messages

  • Infotype 0002: Exception INTERNAL_ERROR after saving

    Hi All
    This error we are getting when we Applied Service package 18. 
    within a hiring action, after you save infotype 0002 ("Personal Data"), the exception INTERNAL_ERROR occurs with the runtime error RAISE_EXCEPTION.
    The exception is triggered in the method CHECK_AUTHORIZATION in the class CL_HRPAD00AUTH_CHECK_STD.
    So if any body is getting this error then please Apply this SAP Note 1366651 which is released By SAP on 20 July 2009.
    Thanks & Regards
    Gaurav Mittal
    Technical Consultant - SAP HR
    Edited by: Gaurav Mittal on Jul 21, 2009 3:13 AM

    What are the logs saying? You will most likely have a bit of code that is incorrect.
    Log into the Coldfusion administrator and have a look at application.log or coldfusion-out.log. It should tell you what the error is and possibly the line number.

  • Internal error: FM RUSHURMASE1 , exception: internal_error

    1 - Issue Summary:Top down:,USERCLONE, CENTER / CENTER, 1, 026, (Internal error: FM RUSHURMASE1 , exception: internal_error)
    Message Type    - USERCLONE
    Error Message - Internal error: FM RUSHURMASE1 , exception: internal_error
    Status ID - 1
    Message No - 026
    Status of the IDoc - 51
    I'm getting the above error information for the IDOC status 51
    And i'm trying to check this function module RUSHURMASE1 in se37. But it is not there. Why?
    Could you please help me. How to solve this problem.
    Thanks,
    Srini

    This this from a new install or on that been running for awhile?

  • Error cannot be classified (unknown exception triggered) in smartform

    Hi,
    When i execute the smartform. i am getting error message "Error cannot be classified (unknown exception triggered) "
    error message ID : SSFCOMPOSER
    error Message No.: 003.
    None of the smartforms are working. Please provide me the solution for this.
    Regards,
    Sree

    Hi,
    Please check the OSS note 567778.
    To check it. Goto snote tcode, then follow the path: Goto-> Download SAP note -> Give the note number 567778
    After that It will say that note has been downloaded. Now follow the path: Goto-> SAP note Browser, here give the note number again.
    Check the implementation status.. Let me know....
    Is it solving your problem?
    Regards,
    Lokesh.
    Edited by: Lokesh Tarey on Apr 22, 2010 10:47 AM

  • INTERNAL_ERROR when testing Smartforms FM

    Hi Experts,
    after modification of a SmartForm, I tried to execute the associated FM and I got this message:
    Exception       INTERNAL_ERROR
    Message ID:          SSFCOMPOSER                Message number:           178
    Message:
    Line 3 column 1 do not exist.
    I've deleted this Line 3 Col 1 in the SmartForm because I don't need it, how can I re-generate the FM ?
    Regards,
    David

    May be that deleted line number is being used by some text elements. So check if any texts are using that line and modify accordingly.
    To find out where the problem is before running the smartform , just use Tcode SMARTFORM_TRACE and press Switch On button.
    Then after getting the error go to the SMARTFORM_TRACE tcode and see the log under Traces in Database.
    That will pin point where the problem.
    Do remember to switch of the trace once you are done with this problem.
    Regards
    Karthik D

  • Exception condition "INTERNAL_ERROR" raised

    Runtime Errors         RAISE_EXCEPTION
    Date and Time          21.08.2014 21:53:43
    What happened?
         The current ABAP/4 program encountered an unexpected
         situation.
    What can you do?
         Note down which actions and inputs caused the error.
         To process the problem further, contact you SAP system
         administrator.
         Using Transaction ST22 for ABAP Dump Analysis, you can look
         at and manage termination messages, and you can also
         keep them for a long time.
    Error analysis
         A RAISE statement in the program "SAPLCEI0" raised the exception
         condition "INTERNAL_ERROR".
         Since the exception was not intercepted by a superior
         program, processing was terminated.
         Short description of exception condition:
         For detailed documentation of the exception condition, use
         Transaction SE37 (Function Library). You can take the called
         function module from the display of active calls.
    How to correct the error
        If the error occures in a non-modified SAP program, you may be able to
        find an interim solution in an SAP Note.
        If you have access to SAP Notes, carry out a search with the following
        keywords:
        "RAISE_EXCEPTION" " "
        "SAPLCEI0" or "LCEI0U30"
        "VC_I_GET_CONFIGURATION"
        or
        "SAPLCEI0" "INTERNAL_ERROR"
        or
        "SAPMSSY1 " "INTERNAL_ERROR"
        If you cannot solve the problem yourself and want to send an error
        notification to SAP, include the following information:
        1. The description of the current problem (short dump)
           To save the description, choose "System->List->Save->Local File
        (Unconverted)".
        2. Corresponding system log
           Display the system log by calling transaction SM21.
           Restrict the time interval to 10 minutes before and five minutes
        after the short dump. Then choose "System->List->Save->Local File
        (Unconverted)".
        3. If the problem occurs in a problem of your own or a modified SAP
        program: The source code of the program
           In the editor, choose "Utilities->More
        Utilities->Upload/Download->Download".
        4. Details about the conditions under which the error occurred or which
        actions and input led to the error.
    System environment
        SAP-Release 700
        Application server... "sap01717"
        Network address...... "10.61.89.105"
        Operating system..... "Linux"
        Release.............. "2.6.40-0.8-default"
        Hardware type........ "x86_64"
        Character length.... 16 Bits
        Pointer length....... 64 Bits
        Work process number.. 15
        Shortdump setting.... "full"
        Database server... "sap01716"
        Database type..... "ORACLE"
        Database name..... "QWT"
        Database user ID.. "SAPDAT"
        Terminal................. "10.61.31.114"
        Char.set.... "C"
        SAP kernel....... 720
        created (date)... "Mar 17 2013 18:46:25"
        create on........ "Linux GNU SLES-11 x86_64 cc4.3.4 use-pr121116"
        Database version. "OCI_102, 11.2.0.3.0, V1, default"
        Patch level. 420
        Patch text.. " "
        Database............. "ORACLE 10.1.0.*.*, ORACLE 10.2.0.*.*, ORACLE 11.2.*.*.*"
        SAP database version. 720
        Operating system..... "Linux 2.6, Linux 3"
        Memory consumption
        Roll.... 0
        EM...... 16759232
        Heap.... 0
        Page.... 16384
        MM Used. 14978448
        MM Free. 1777544
    User and Transaction
        Client.............. 500
        User................ "RFC_TAULIA"
        Language Key........ "E"
        Transaction......... " "
        Transactions ID..... "53F6515E320E5BBBE10000000A3D5969"
        Program............. "SAPLCEI0"
        Screen.............. "SAPMSSY1 3004"
        Screen Line......... 2
        Information on caller of Remote Function Call (RFC):
        System.............. "########"
        Database Release.... 720
        Kernel Release...... 720
        Connection Type..... "E" (2=R/2, 3=ABAP System, E=Ext., R=Reg. Ext.)
        Call Type........... "synchronous and non-transactional (emode 0, imode 0)"
        Inbound TID.........." "
        Inbound Queue Name..." "
        Outbound TID........." "
        Outbound Queue Name.." "
        Client.............. "###"
        User................ "############"
        Transaction......... " "
        Call Program........."SAPJCo30"
        Function Module..... "/TAULIA/CT_RFC_BUS_DOC_GET"
        Call Destination.... "SAPR3"
        Source Server....... "SWDETDOLPHPODD"
        Source IP Address... "10.61.31.114"
        Additional information on RFC logon:
        Trusted Relationship " "
        Logon Return Code... 0
        Trusted Return Code. 0
        Note: For releases < 4.0, information on the RFC caller are often
        only partially available.
    Information on where terminated
        Termination occurred in the ABAP program "SAPLCEI0" - in
         "VC_I_GET_CONFIGURATION".
        The main program was "SAPMSSY1 ".
        In the source code you have the termination point in line 259
        of the (Include) program "LCEI0U30".

    Hi Arun,
    the exception INTERNAL_ERROR of function module VC_I_GET_CONFIGURATION hasn't been caught, which leads to a short dump.
    Check, where INTERNAL_ERROR is raised in your system In our system the only remaining code is after call of function module CUCQ_GET_CONFIGURATION_PARAMS.
    Please try to debug, why this exception is raised.
    Regards,
    Klaus

  • SSFCOMPOSER - 154 - No output request open. End not possible.

    Hi Experts,
    I'm trying to print multiple smartforms using FMs SSF_OPEN and SSF_CLOSE. Inside the main program RBDAPP01 (Inbound processing for IDOCS) there is a loop at the IDOCS to be processed. Deep within the processing, we have a custom FM being called which prints smartforms. Since there is a loop at the calling main program, I have organized the code in the custom FM such that the first IDOC calls SSF_OPEN and the last IDOC calls SSF_CLOSE, so that all IDOCS in between will be able to print their smartforms. Here is the call stack:
    8
    SAPLZCUSTOM                   
    ZCUSTOMPROGRAM                             
    113
    FUNCTION                     
    ZCUSTOMPROGRAM                                         
    7
    SAPLPPC1                               
    ZCUSTOMPROGRAM     
    136
    FUNCTION                     
    KK2A_GET_DATA_FROM_IDOC                                     
    7
    SAPLPPC1                               
    LPPC1U01                               
    1
    FUNCTION                     
    KK2A_GET_DATA_FROM_IDOC                                     
    6
    SAPLBD20                               
    LBD20F0A                               
    454
    FORM                         
    IDOCS_PASS_TO_APPLICATION                                   
    5
    SAPLBD20                               
    LBD20F0B                               
    69
    FORM                         
    IDOCS_PROCESS                                               
    4
    SAPLBD20                               
    LBD20U05                               
    260
    FUNCTION                     
    IDOC_INPUT                                                  
    3
    SAPLEDIR                               
    LEDIRU02                               
    182
    FUNCTION                     
    IDOC_START_INBOUND                                          
    2
    SAPLBD12                               
    LBD12U04                               
    37
    FUNCTION                     
    APPLICATION_IDOC_POST_IMMEDIAT                              
    1
    RBDAPP01                               
    RBDAPP01                               
    388
    EVENT                        
    START-OF-SELECTION                                          
    The problem is:
    1. When I only have 1 IDOC being processed, SSF_OPEN and SSF_CLOSE happens in the custom FM at the same time. This creates a successful spool.
    2. Whereas, when I have 2 or more IDOCS, SSF_OPEN happens in the first IDOC, but then it goes back to the calling program, and then when the last IDOC is encountered SSF_CLOSE is called. The FM SSF_CLOSE in this scenario calls the exception INTERNAL_ERROR (sy-subrc = 2).
    The system message is SSFCOMPOSER - 154 - No output request open. End not possible.
    Why is this happening? Is it because that other programs (calling programs) may have affected the status of SSF_OPEN? It seems that the SSF_OPEN is no longer open.
    Thanks in Advanced,
    Jack

    No, it will not hold the smartform open, but you don't need to hold it open in order for printout to be accumulated in one spool. Spool system does the accumulation automatically, provided the spool requests that are to be added to an existing spool request are:
    - generated in the same transaction and
    - have the same attributes (such as user, title, output device, client from which the request was issued, number of copies, priority, cover sheet setting, archive mode, and ABAP session number).
    Important is: where do OUTPUT_OPTIONS like printer come from currently? Is print parameters popup displayed on first Idoc for user to choose printer and options? Or do you use USER_SETTINGS = 'X' to simply take over defaults from user master? If the print options dialog is displayed, it needs to be controlled as well so it's displayed only once.
    Assuming print options come from the user in dialog, the logic without explicit open/close could look somewhat like this:
    On first idoc:
    - call SSF_OPEN  importing  JOB_OUTPUT_OPTIONS to display print options dialog; move-corresponding JOB_OUTPUT_OPTIONS to global OUTPUT_OPTIONS;
    - set OUTPUT_OPTIONS-TDNEWID = 'X' and clear  OUTPUT_OPTIONS-TDFINAL, to ensure new spool will be started (overriding user choices for these parameters!);
    - if the user has set OUTPUT_OPTIONS-TDIMMED = 'X' save it globally and clear it;
    - set CONTROL_PARAMETERS-NO_OPEN = 'X';
    On subsequent idoc:
    - clear OUTPUT_OPTIONS-TDNEWID;
    - clear CONTROL_PARAMETERS-NO_OPEN;
    On last idoc:
    - set OUTPUT_OPTIONS-TDFINAL = 'X' (this is not absolutely necessary, but prevents further appending to the spool);
    - restore OUTPUT_OPTIONS-TDIMMED from the value saved on first idoc;
    Calling Smartform:
    - set CONTROL_PARAMETERS-NO_DIALOG = 'X';
    - call smartform passing OUTPUT_OPTIONS and CONTROL_PARAMETERS;
    The logic is somewhat complicated; I'd wrap it in a class (singleton, which would be de-instantiated after last idoc) to avoid global data and code other than simple method call(s) in FM.
    Even if you decide to refactor the logic, it would still be important to understand, I think, why the current logic does not work (where and why smartform gets closed)... Maybe there are some nasty "surprises" somewhere, and your current algorithm should work.
    cheers
    Janis

  • How to place the camma in currency

    Hi All,
    I have a currency field.
    For country Kora, they don't  have  decimal places in currency.
    52,000.00 KOR   is one exaple.  Here i have to   place camma in currency as below.
    5,200,000.  
    how to solve the aove problem.
    I don't know where and how many camma will be in my currency field.
    Thanks,
    Kishan

    Hi All,
    as per dilip it is working.  But i want to   move the converted format currency into other field.
    Because i want display it in smartform.
    In program line  ... if i write  write gd_disval CURRENCY 'KOR' .
    it is not working.
    i followed other way as below it is working
    CALL FUNCTION 'CURRENCY_AMOUNT_SAP_TO_DISPLAY'
           EXPORTING
              CURRENCY        =  p_discur
              AMOUNT_INTERNAL =   p_intval 
            IMPORTING
              AMOUNT_DISPLAY  = gd_disval  
            EXCEPTIONS
              INTERNAL_ERROR  = 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.
    It is giving the   exact format.    But i am getting it as below:  5,200,000.000.
    But i want only  5,200,000.   The filed gd_disval    is of type   " WMTO_S-AMOUNT".
    i am unale to split it at  ".". so that i can remove after dot.  but iam getting error .  it is of not type D,C,T..
    Any boady can help me.
    Thanks,,
    Kishan

  • Attachments: Read comments (Personal notes)

    Hello everybody.
    I need to extract the personal notes attached to an employee. I mean:
    Go to PB30; insert a pernr; then you have a little icon just down the tick of the transactions bar; click on the arrow and then click on "List of attachments" (Or something like that... I´m using the spanish version). Now you get a list of the attachments and you can click on one of them and read it. I need that to write them down into a SmartForm, so I need to extract them with code.
    I´ve been able to input them with SO_OBJECT_INSERT and BINARY_RELATION_CREATE but I´m not able to output them.
    Thanks in advance for your help.

    Hi,
    Please check the following method to get binary data from GOS
    is_object-instid = v_bo_id.
    is_object-typeid = v_botype.
    is_object-catid = 'BO'.
    try.
    call method cl_binary_relation=>read_links_of_binrel
    exporting
    is_object = is_object
    ip_relation = 'NOTE'   " << I think it will NOTE or  MESSAGE i am confused
    importing
    et_links = et_links.
    then use
    call function 'SREL_GET_NEXT_RELATIONS'
      exporting
        object               = lo_is_object_a
         ROLETYPE             =
          relationtype         = p_reltyp
         MAX_HOPS             = 1
         INCL_APPLRELS        = ' '
         EXCL_ROLES           =
         EXCL_RELATIONS       =
        tables
          links                = lt_links
         ROLES                =
         APPLLINKS            =
       exceptions
         internal_error       = 1
         no_logsys            = 2
         others               = 3
    if not worked then try
    fm  BDS_BUSINESSDOCUMENT_GET_TAB
    and also check the following link.
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/abap-SendingGOSattachmentstoanemailaddress&
    aRs

  • Getting problem in the code

    Hi experts,
    kindly check the following code.
    when i click the first radio button it should take that date..When i click the seconde radio botton the data should come from the range of the dates. I have done this and not able to get proper data.
    ( radio buttons r6 & r7 ).
    *& Report  Z_TEST                                                      *
    report YSDPRICEREP no standard page heading
                      line-size 80                          "M02
                       line-size 132
                       line-count 65
                       message-id Z1.
    *-- Table Declaration
    Tables : KONP,                         " Conditions (Item)
             KONM,                         " Scale Record
             MARA,
             KNVV,
             A004,                         " Material Cond
             A005,                         " Cust Material Cond
             A997,                         " All Cond
             A055.                         " VTWEG, WERKS, VKORG Cond
    M02 start
    TABLES : KONH,                         " Conditions (Header)
             A994,                         " Cust/Material @ cond typ PB01
             A992.                         " Sorg/DC/Plant/Mat @ c typ YCOM
    M02 end
    *-- structure for KONP + COND Rec
    types: begin of inforec,
           vtweg   like a004-vtweg,
           kunnr   like A005-kunnr,        " Customer
           matnr   like mara-matnr,        " Material
           knumh   like konh-knumh,        " Cond rec #
           kbetr   like konp-kbetr,        " Rate
           konwa   like konp-konwa,        " Rate unit
           kpein   like konp-kpein,        " Cond pricing unit
           DATBI   LIKe A996-DATBI,        " Validity end date        "M02
           DATAB   LIKE A996-dATAB,        " Validity start date      "M02
           ERNAM   LIKE KONH-ERNAM,        " User ID                  "M02
           vkorg   like A997-vkorg,        " SOrg                     "M02
           werks   like A997-werks,        " Plant                    "M02
           mfrpn   like mara-mfrpn,                             "M03
           erdat   like konh-erdat,        " Creation date  "M04
         end of inforec.
    *-- Scale table structure
    types : begin of ikonm,
           kstbm   like konm-kstbm,        " Cond scale qty
           kbetr   like konm-kbetr,        " Rate
           end of ikonm.
    *-- Working area
    data : tmatnr like mara-matnr,
           tkunnr like knvv-kunnr,
           jpy_amt type p decimals 2,
           tamt type p decimals 2,
           i_inforec type inforec occurs 1 with header line,
           i_konm type ikonm occurs 1 with header line,
           s_flag.      " scale output alignment indicator
    parameters: pkschl like a004-kschl,
                pvkorg like a004-vkorg default '3000',
                pwerks like a055-werks.
    SELECT-OPTIONS: svtweg for a004-vtweg,
                    skunnr for a005-kunnr,
                    smatnr for mara-matnr,
                    sprdha for mara-prdha.
    parameters pvalid like sy-datum default sy-datum.
    *M06....START
    SELECTION-SCREEN BEGIN OF BLOCK test WITH FRAME TITLE TEXT-004.
      SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(25) text-005.
        PARAMETERS: r6 RADIOBUTTON GROUP xyz.
        SELECTION-SCREEN POSITION 33.
        PARAMETERS: Pdate TYPE d default sy-datum.
      SELECTION-SCREEN END OF LINE.
      SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(25) text-006.
        PARAMETERS: r7 RADIOBUTTON GROUP xyz.
        SELECTION-SCREEN POSITION 30.
      select-options prange for sy-datum.
      SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK test.
    *M06....END
    *if r6 = 'x'.
    *pvalid = pdate.
    *elseif r7 = 'x'.
    *free: pvalid,pdate.
    *endif.
    radio button grp for PR00 combinations
    SELECTION-SCREEN BEGIN OF BLOCK BLOCK1 WITH FRAME TITLE TEXT-001.
    PARAMETERS r4 RADIOBUTTON GROUP radi.
    PARAMETERS r5 RADIOBUTTON GROUP radi.
    SELECTION-SCREEN END OF BLOCK BLOCK1.
    radio button grp for ZI02 combinations
    SELECTION-SCREEN BEGIN OF BLOCK BLOCK2 WITH FRAME TITLE TEXT-002.
    PARAMETERS r997 RADIOBUTTON GROUP rade.
    PARAMETERS r55 RADIOBUTTON GROUP rade.
    SELECTION-SCREEN END OF BLOCK BLOCK2.
    SELECTION-SCREEN BEGIN OF BLOCK BLOCK3 WITH FRAME TITLE TEXT-003.
    PARAMETERS cscale as checkbox.
    SELECTION-SCREEN END OF BLOCK BLOCK3.
    at selection-screen.
      if pkschl = 'PR00'.
        if ( pvkorg is initial ) or ( svtweg is initial ).
          message E022.
        endif.
      elseif pkschl = 'ZI02'.
        if ( pvkorg is initial ) or ( svtweg is initial ).
          message E022.
        endif.
      elseif pkschl = 'PI01'.
        if ( pvkorg is initial ) or ( pwerks is initial ).
          message E170.
        endif.
    M02 start
      elseif pkschl = 'YCOM'.
        if ( pvkorg is initial ) or ( pwerks is initial ).
          message E023.
        endif.
      elseif pkschl = 'PB01'.
        if ( pvkorg is initial ) or ( svtweg is initial ).
          message E022.
        endif.
    M02 end
      else.
        message E021.
      endif.
      if pvalid is initial.
        message E024.
    elseif prange is initial.  "M06
      message E024.
      endif.
    start-of-selection.
    fill s_matnr with correct entries. 08072002 Zir
      call function 'Z_FILL_MATNR_SELTAB'
           TABLES
                s_matnr = smatnr.
      check smatnr-low ne 'None'.  "Added by Bala @ M05
    fill up select options with * if not input.
      if smatnr is initial.
        smatnr-sign = 'I'.
        smatnr-option = 'CP'.
        smatnr-low = '*'.
      endif.
      if skunnr is initial.
        skunnr-sign = 'I'.
        skunnr-option = 'CP'.
        skunnr-low = '*'.
      endif.
      perform collect_data.
      perform write_to_list.
    *&      Form  COLLECT_DATA
    FORM collect_data.
      clear i_inforec.
      refresh i_inforec.
    PR00 with material
      if ( pkschl = 'PR00' ) and ( r4 = 'X' ).
       select vtweg matnr knumh                               "M02
        select vtweg matnr knumh datbi datab                    "M02
                        into corresponding fields of i_inforec
                        from A004
                        where kappl eq 'V'
                        and kschl eq pkschl
                        and vkorg eq pvkorg
                        and vtweg in svtweg
                        and matnr in smatnr
                        and datbi ge pvalid
                        and datab le pvalid
                        and datab ge prange-low     "M06
                        and datbi le prange-high.   "M06
          if sy-subrc = 0.
    if filtered by product hierachy
            if not ( sprdha is initial ).
              select single mfrpn into i_inforec-mfrpn from mara
                                              where prdha in sprdha
                                              and matnr = i_inforec-matnr
                                              and lvorm ne 'X'.
              check sy-subrc eq 0.
            else.
              select single mfrpn into i_inforec-mfrpn from mara
                                              where matnr = i_inforec-matnr
                                              and lvorm ne 'X'.
              check sy-subrc eq 0.
            endif.
            select single kbetr konwa kpein
                          into corresponding fields of i_inforec
                          from konp where knumh = i_inforec-knumh
                             and loevm_ko ne 'X'.
            check sy-subrc eq 0.
            if i_inforec-konwa = 'JPY'.
              tamt = i_inforec-kbetr.
              perform get_display_amount.
              i_inforec-kbetr = jpy_amt.
            endif.
            append i_inforec.
            clear i_inforec.
          else.
            clear i_inforec.
          endif.
        endselect.
    PR00 with Cust/ Material
      elseif ( pkschl = 'PR00' ) and ( r5 = 'X' ).
       select vtweg kunnr matnr knumh                              "M02
        select vtweg kunnr matnr knumh datbi datab              "M02
                        into corresponding fields of i_inforec
                        from A005
                        where kappl eq 'V'
                        and kschl eq pkschl
                        and vkorg eq pvkorg
                        and vtweg in svtweg
                        and kunnr in skunnr
                        and matnr in smatnr
                        and datbi ge pvalid
                        and datab le pvalid
                        and datab ge prange-low     "M06
                        and datbi le prange-high.   "M06
          if sy-subrc = 0.
    filtered by product hierachy
            if not ( sprdha is initial ).
              select single mfrpn into i_inforec-mfrpn from mara
                                              where prdha in sprdha
                                              and matnr = i_inforec-matnr
                                              and lvorm ne 'X'.
              check sy-subrc eq 0.
            else.
              select single mfrpn into i_inforec-mfrpn from mara
                                              where matnr = i_inforec-matnr
                                              and lvorm ne 'X'.
              check sy-subrc eq 0.
            endif.
            select single kunnr into tkunnr from knvv
                                            where kunnr = i_inforec-kunnr
                                            and loevm ne 'X'.
            check sy-subrc eq 0.
            select single kbetr konwa kpein
                            into corresponding fields of i_inforec
                            from konp where knumh = i_inforec-knumh
                            and loevm_ko ne 'X'.
            check sy-subrc eq 0.
            if i_inforec-konwa = 'JPY'.
              tamt = i_inforec-kbetr.
              perform get_display_amount.
              i_inforec-kbetr = jpy_amt.
            endif.
            append i_inforec.
            clear i_inforec.
          else.
            clear i_inforec.
          endif.
        endselect.
    ZI02 with Plant only
      elseif ( pkschl = 'ZI02' ) and ( r55 = 'X' ).
       select matnr knumh                                     "M02
        select matnr knumh datbi datab                          "M02
                        into corresponding fields of i_inforec
                        from A055
                        where kappl eq 'V'
                        and kschl eq pkschl
                        and vkorgau eq pvkorg
                        and werks eq pwerks
                        and matnr in smatnr
                        and datbi ge pvalid
                        and datab le pvalid
                        and datab ge prange-low     "M06
                        and datbi le prange-high.   "M06
          if sy-subrc = 0.
    filtered by product hierachy
            if not ( sprdha is initial ).
              select single mfrpn into i_inforec-mfrpn from mara
                                              where prdha in sprdha
                                              and matnr = i_inforec-matnr
                                              and lvorm ne 'X'.
              check sy-subrc eq 0.
            else.
              select single mfrpn into i_inforec-mfrpn from mara
                                              where matnr = i_inforec-matnr
                                              and lvorm ne 'X'.
              check sy-subrc eq 0.
            endif.
            select single kbetr konwa kpein
                            into corresponding fields of i_inforec
                            from konp where knumh = i_inforec-knumh
                             and loevm_ko ne 'X'.
            check sy-subrc eq 0.
            if i_inforec-konwa = 'JPY'.
              tamt = i_inforec-kbetr.
              perform get_display_amount.
              i_inforec-kbetr = jpy_amt.
            endif.
            append i_inforec.
            clear i_inforec.
          else.
            clear i_inforec.
          endif.
        endselect.
    ZI02 with all
      elseif ( pkschl = 'ZI02' ) and ( r997 = 'X' ).
       select vtweg kunnr matnr knumh                              "M02
        select vtweg kunnr matnr knumh datbi datab              "M02
                        into corresponding fields of i_inforec
                      from A997                                    "M01
                        from A996                               "M01
                        where kappl eq 'V'
                        and kschl eq pkschl
                        and vkorg eq pvkorg
                        and vtweg in svtweg
                      and werks eq pwerks                          "M01
                        and kunnr in skunnr
                        and matnr in smatnr
                        and datbi ge pvalid
                        and datab le pvalid
                        and datab ge prange-low     "M06
                        and datbi le prange-high.   "M06
          if sy-subrc = 0.
    filtered by product hierachy
            if not ( sprdha is initial ).
              select single mfrpn into i_inforec-mfrpn from mara
                                              where prdha in sprdha
                                              and matnr = i_inforec-matnr
                                              and lvorm ne 'X'.
              check sy-subrc eq 0.
            else.
              select single mfrpn into i_inforec-mfrpn from mara
                                              where matnr = i_inforec-matnr
                                              and lvorm ne 'X'.
              check sy-subrc eq 0.
            endif.
            select single kunnr into tkunnr from knvv
                                            where kunnr = i_inforec-kunnr
                                            and loevm ne 'X'.
            check sy-subrc eq 0.
            select single kbetr konwa kpein
                            into corresponding fields of i_inforec
                            from konp where knumh = i_inforec-knumh
                               and loevm_ko ne 'X'.
            check sy-subrc eq 0.
            if i_inforec-konwa = 'JPY'.
              tamt = i_inforec-kbetr.
              perform get_display_amount.
              i_inforec-kbetr = jpy_amt.
            endif.
            append i_inforec.
            clear i_inforec.
          else.
            clear i_inforec.
          endif.
        endselect.
    PI01 with Plant only
      elseif ( pkschl = 'PI01' ).
       select matnr knumh                                     "M02
        select matnr knumh datbi datab                          "M02
                        into corresponding fields of i_inforec
                        from A055
                        where kappl eq 'V'
                        and kschl eq pkschl
                        and vkorgau eq pvkorg
                        and werks eq pwerks
                        and matnr in smatnr
                        and datbi ge pvalid
                        and datab le pvalid
                        and datab ge prange-low     "M06
                        and datbi le prange-high.   "M06
          if sy-subrc = 0.
    filtered by product hierachy
            if not ( sprdha is initial ).
              select single mfrpn into i_inforec-mfrpn from mara
                                              where prdha in sprdha
                                              and matnr = i_inforec-matnr
                                              and lvorm ne 'X'.
              check sy-subrc eq 0.
            else.
              select single mfrpn into i_inforec-mfrpn from mara
                                              where matnr = i_inforec-matnr
                                              and lvorm ne 'X'.
              check sy-subrc eq 0.
            endif.
            select single kbetr konwa kpein
                            into corresponding fields of i_inforec
                            from konp where knumh = i_inforec-knumh
                             and loevm_ko ne 'X'.
            check sy-subrc eq 0.
            if i_inforec-konwa = 'JPY'.
              tamt = i_inforec-kbetr.
              perform get_display_amount.
              i_inforec-kbetr = jpy_amt.
            endif.
            append i_inforec.
            clear i_inforec.
          else.
            clear i_inforec.
          endif.
        endselect.
      endif.
    M02 start
    PB01 with Cust/ Material
      if ( pkschl = 'PB01' ).
    Insert by Cindy: To segregate PB01 by DC, since Price Master not
    maintained by DC. Check Customer master for info
        select distinct A994kunnr A994matnr A994knumh A994datbi
         A994~datab into corresponding fields of i_inforec
                       from A994 as A994 inner join knvv as knvv
                       on A994kunnr = knvvkunnr
                       where kappl eq 'V'
                        and kschl eq pkschl
                       and A994~kunnr in skunnr
                       and knvv~vtweg in svtweg
                       and knvv~loevm ne 'X'
                       and A994~matnr in smatnr
                       and A994~datbi ge pvalid
                       and A994~datab le pvalid
                       and A994~datab ge prange-low     "M06
                       and A994~datbi le prange-high.   "M06
    commented by Cindy
    *select kunnr matnr knumh datbi datab
                      into corresponding fields of i_inforec
                      from A994
                      where kappl eq 'V'
                      and kschl eq pkschl
                      and kunnr in skunnr
                      and matnr in smatnr
                      and datbi ge pvalid
                      and datab le pvalid.
    end
          if sy-subrc = 0.
    filtered by product hierachy
            if not ( sprdha is initial ).
              select single mfrpn into i_inforec-mfrpn from mara
                                              where prdha in sprdha
                                              and matnr = i_inforec-matnr
                                              and lvorm ne 'X'."M03
              check sy-subrc eq 0.
            else.
              select single mfrpn into i_inforec-mfrpn from mara
                                              where matnr = i_inforec-matnr
                                              and lvorm ne 'X'."M03
              check sy-subrc eq 0.
            endif.
            select single kunnr into tkunnr from knvv
                                            where kunnr = i_inforec-kunnr
                                            and loevm ne 'X'.
            check sy-subrc eq 0.
            select single kbetr konwa kpein
                            into corresponding fields of i_inforec
                            from konp where knumh = i_inforec-knumh
                               and loevm_ko ne 'X'.
            check sy-subrc eq 0.
            if i_inforec-konwa = 'JPY'.
              tamt = i_inforec-kbetr.
              perform get_display_amount.
              i_inforec-kbetr = jpy_amt.
            endif.
            append i_inforec.
            clear i_inforec.
          else.
            clear i_inforec.
          endif.
        endselect.
      endif.
    YCOM with SOrg/DC/Plant/Mat
      if ( pkschl = 'YCOM' ) and ( r4 = 'X' ).
        select vtweg matnr knumh datbi datab vkorg werks
                        into corresponding fields of i_inforec
                        from A992
                        where kappl eq 'V'
                        and kschl eq pkschl
                       and vkorg eq pvkorg
                        and vtweg in svtweg
                       and werks eq pwerks
                        and matnr in smatnr
                        and datbi ge pvalid
                        and datab le pvalid
                        and datab ge prange-low     "M06
                        and datbi le prange-high.   "M06
          if sy-subrc = 0.
    if filtered by product hierachy
            if not ( sprdha is initial ).
              select single mfrpn into i_inforec-mfrpn from mara
                                              where prdha in sprdha
                                              and matnr = i_inforec-matnr
                                              and lvorm ne 'X'."M03
              check sy-subrc eq 0.
            else.
              select single mfrpn into i_inforec-mfrpn from mara
                                              where matnr = i_inforec-matnr
                                              and lvorm ne 'X'."M03
              check sy-subrc eq 0.
            endif.
            select single kbetr konwa kpein
                          into corresponding fields of i_inforec
                          from konp where knumh = i_inforec-knumh
                             and loevm_ko ne 'X'.
            check sy-subrc eq 0.
            if i_inforec-konwa = 'JPY'.
              tamt = i_inforec-kbetr.
              perform get_display_amount.
              i_inforec-kbetr = jpy_amt.
            endif.
            i_inforec-kbetr = i_inforec-kbetr / 10. "M03
            append i_inforec.
            clear i_inforec.
          else.
            clear i_inforec.
          endif.
        endselect.
      endif.
    YCOM with SOrg/DC/Plant/Cust/Mat
      if ( pkschl = 'YCOM' ) and ( r5 = 'X' ).
        select vtweg kunnr matnr knumh datbi datab vkorg werks
                        into corresponding fields of i_inforec
                        from A997
                        where kappl eq 'V'
                        and kschl eq pkschl
                       and vkorg eq pvkorg
                        and vtweg in svtweg
                       and werks eq pwerks
                        and kunnr in skunnr
                        and matnr in smatnr
                        and datbi ge pvalid
                        and datab le pvalid
                        and datab ge prange-low     "M06
                        and datbi le prange-high.   "M06
          if sy-subrc = 0.
    filtered by product hierachy
            if not ( sprdha is initial ).
              select single mfrpn into i_inforec-mfrpn from mara
                                              where prdha in sprdha
                                              and matnr = i_inforec-matnr
                                              and lvorm ne 'X'.
              check sy-subrc eq 0.
            else.
              select single mfrpn into i_inforec-mfrpn from mara
                                              where matnr = i_inforec-matnr
                                              and lvorm ne 'X'.
              check sy-subrc eq 0.
            endif.
            select single kunnr into tkunnr from knvv
                                            where kunnr = i_inforec-kunnr
                                            and loevm ne 'X'.
            check sy-subrc eq 0.
            select single kbetr konwa kpein
                            into corresponding fields of i_inforec
                            from konp where knumh = i_inforec-knumh
                              and loevm_ko ne 'X'.
            check sy-subrc eq 0.
            if i_inforec-konwa = 'JPY'.
              tamt = i_inforec-kbetr.
              perform get_display_amount.
              i_inforec-kbetr = jpy_amt.
            endif.
            i_inforec-kbetr = i_inforec-kbetr / 10. "M03
            append i_inforec.
            clear i_inforec.
          else.
            clear i_inforec.
          endif.
        endselect.
      endif.
    M02 end
      read table i_inforec.
      if sy-tfill eq 0.
        message I016.
      endif.
    ENDFORM.                               " F_GET_KONH_KONP
    *&      Form  CHECK_SCALES
    FORM check_scales.
      clear: i_konm.
      refresh: i_konm.
      select kstbm
             kbetr
        appending corresponding fields of table i_konm
        from konm
        where knumh = i_inforec-knumh.
      check sy-subrc = 0.
    depending on scale output ind. diff alignment
      if s_flag = 2.
        write: /29(32) SY-ULINE.
        write: /29 'SCALE QUANTITY', 57 'RATE'.
        write: /29(32) SY-ULINE.
        loop at i_konm.
          write: /25 i_konm-kstbm, 46 i_konm-kbetr.
        endloop.
        write: /29(32) SY-ULINE.
      else.
        write: /19(32) SY-ULINE.
        write: /19 'SCALE QUANTITY', 47 'RATE'.
        write: /19(32) SY-ULINE.
        loop at i_konm.
          write: /15 i_konm-kstbm, 36 i_konm-kbetr.
        endloop.
        write: /19(32) SY-ULINE.
      endif.
      skip.
    ENDFORM.                               " F_GET_KONM
    *&      Form  WRITE_TO_LIST
    FORM WRITE_TO_LIST.
    sorting based on customer & dist.channel or dist. channel based on
    earlier selections
      if ( ( pkschl = 'PR00' ) and ( r4 = 'X' ) ) or
         ( ( pkschl = 'ZI02' ) and ( r55 = 'X' ) ) or
         ( pkschl = 'PI01' ).
        sort i_inforec by vtweg  mfrpn .   "matnr.
      elseif ( ( pkschl = 'PR00' ) and ( r5 = 'X' ) ) or
             ( ( pkschl = 'ZI02' ) and ( r997 = 'X' ) ).
        sort i_inforec by kunnr vtweg mfrpn ."matnr.
      endif.
    M02 start
      if pkschl = 'YCOM' and r4 = 'X'.
        sort i_inforec by vtweg mfrpn .    "matnr.
      elseif pkschl = 'YCOM' and r5 = 'X'.
        sort i_inforec by kunnr vtweg mfrpn ."matnr.
      endif.
      if pkschl = 'PB01'.
        sort i_inforec by kunnr mfrpn .    "matnr.
      endif.
    M02 end
      loop at i_inforec.
    **M02 start
        if pvkorg is initial.
          if pwerks is initial.
          else.
            check i_inforec-werks eq pwerks.
          endif.
        else.
          if pwerks is initial.
          check i_inforec-vkorg eq pvkorg.
            check i_inforec-werks eq pwerks.
          else.
            check i_inforec-vkorg eq pvkorg.
            check i_inforec-werks eq pwerks.
          endif.
        endif.
        select single ernam erdat into corresponding
          fields of i_inforec from konh
          where knumh = i_inforec-knumh.
    **M02 end
        clear s_flag.
       if ( pkschl = 'PR00' ) and ( r4 = 'X' ).                       "M02
        if ( pkschl = 'PR00' or pkschl = 'YCOM' ) and ( r4 = 'X' )."M02
          perform write_no_cust.
       elseif ( pkschl = 'PR00' ) and ( r5 = 'X' ).                   "M02
        elseif ( pkschl = 'PR00' or pkschl = 'YCOM' ) and ( r5 = 'X' )."M02
          perform write_w_cust.
          s_flag = 2.
        elseif ( pkschl = 'ZI02' ) and ( r55 = 'X' ).
          perform write_no_cust.
        elseif ( pkschl = 'ZI02' ) and ( r997 = 'X' ).
          perform write_w_cust.
          s_flag = 2.
        elseif ( pkschl = 'PI01' ).
          perform write_no_cust.
        endif.
    M02 start
        if pkschl = 'PB01'.
          perform write_w_cust.
          s_flag = 2.
        endif.
    M02 end
        if cscale = 'X'.
          perform check_scales.
        endif.
      endloop.
    ENDFORM.                               " OUTPUT
    *&      Form  WRITE_NO_CUST
    FORM WRITE_NO_CUST.
    group by dist.channel
      on change of i_inforec-vtweg.
        if sy-tabix ne 1.
          skip. skip.
        endif.
        write : /1 i_inforec-vtweg.
      endon.
      if pkschl ne 'YCOM'.                                      "M02
        write: /10 i_inforec-matnr, 36 i_inforec-kbetr, 54 i_inforec-konwa.
        write: 62 i_inforec-kpein.
        write: 70 i_inforec-DATAB, '-', i_inforec-DATBI.        "M02
        write: 96 i_inforec-ernam, 107 i_inforec-erdat.       "M02
    M02 start
      else.
        write: /10 i_inforec-matnr, 36 i_inforec-kbetr, 54 i_inforec-konwa.
        write: 60 i_inforec-DATAB, '-', i_inforec-DATBI.
        write: 87 i_inforec-ernam, 98 i_inforec-erdat.
      endif.
    M02 end
    ENDFORM.                               " WRITE_NO_CUST
    *&      Form  WRITE_W_CUST
    FORM WRITE_W_CUST.
    group by customer
      on change of i_inforec-kunnr.
        if sy-tabix ne 1.
          skip. skip.
        endif.
        write : /1 i_inforec-kunnr, 12 i_inforec-vtweg.
      endon.
      if pkschl ne 'PB01'.                                      "M02
        if pkschl ne 'YCOM'.                                    "M02
          write: /20 i_inforec-matnr, 46 i_inforec-kbetr.
          write: 64 i_inforec-konwa, 72 i_inforec-kpein.
          write: 80 i_inforec-DATAB, '-', i_inforec-DATBI.      "M02
          write: 106 i_inforec-ernam, 117 i_inforec-erdat.      "M02
    M02 start
        else.
          write: /20 i_inforec-matnr, 46 i_inforec-kbetr.
          write: 64 i_inforec-konwa.
          write: 70 i_inforec-DATAB, '-', i_inforec-DATBI.
          write: 98 i_inforec-ernam, 109 i_inforec-erdat.
        endif.
      else.
        write: /12 i_inforec-matnr, 38 i_inforec-kbetr.
        write: 56 i_inforec-konwa, 64 i_inforec-kpein.
        write: 72 i_inforec-DATAB, '-', i_inforec-DATBI.
        write: 98 i_inforec-ernam, 109 i_inforec-erdat.
      endif.
    M02 end
    ENDFORM.                               " WRITE_W_CUST
    TOP-OF-PAGE.
    M02 start
      call function 'Z_REPORT_TITLE'
           EXPORTING
                line_size       = sy-linsz
                sy_title        = sy-title
                uline           = 'X'
                first_page_only = ' '.
    M02 end
    WRITE: / 'Valid on: ', pvalid.
    WRITE: / 'Valid on: ', prange-low, ' - ', prange-high. "M06
      write: /1 'Condition type:', pkschl.
    M02 start
      if pkschl ne 'PB01'.
        if pkschl = 'YCOM'.
          if not ( pvkorg is initial ).
            write: 25 'Sales Org:', pvkorg.
            if not ( pwerks is initial ).
              write: '  Plant:', pwerks.
            endif.
          else.
            if not ( pwerks is initial ).
              write: 25 'Plant:', pwerks.
            endif.
          endif.
        else.
    M02 end
          write: 25 'Sales Org:', pvkorg.
          write: 45 'Dist.Channel:', svtweg-low.
        endif.                                                  "M02
      else.
        write: 25 'Sales Org:', pvkorg.
        write: 45 'Dist.Channel:', svtweg-low.
      endif.                                                    "M02
      if pkschl ne 'YCOM'.                                      "M02
        if not ( pwerks is initial ).
          write: '  Plant:', pwerks.
        endif.
      endif.                                                    "M02
      skip.
      if ( ( pkschl = 'PR00' ) and ( r4 = 'X' ) ) or
         ( ( pkschl = 'ZI02' ) and ( r55 = 'X' ) ) or
         ( pkschl = 'PI01' ).
    data extraction from A055 has no dist. chan or customer
        if ( pkschl = 'PR00' ) and ( r4 = 'X' ).
          write: /1 'DIST.C'.
        endif.
        write: 10 'MATERIAL', 46 'PRICE'.
        write: 53 'CURR', 62 'UNIT'.
        write: 70 'VALID FROM', 83 'VALID TO'.                  "M02
        write: 94 'CREATED BY', 107 'CREATE DATE'.              "M02
      elseif ( ( pkschl = 'PR00' ) and ( r5 = 'X' ) ) or
             ( ( pkschl = 'ZI02' ) and ( r997 = 'X' ) ).
        write: /1 'CUSTOMER', 12 'DIST.C', 20 'MATERIAL'.
        write: 56 'PRICE', 63 'CURR', 72 'UNIT'.
        write: 80 'VALID FROM', 93 'VALID TO'.                  "M02
        write: 104 'CREATED BY',117 'CREATE DATE'.              "M02
      endif.
    M02 start
      if pkschl = 'YCOM' and r4 = 'X'.
        write: /1 'DIST.C'.
        write: 10 'MATERIAL', 46 'COMM PERC'.
        write: 60 'VALID FROM', 73 'VALID TO'.
        write: 85 'CREATED BY', 98 'CREATE DATE'.
      elseif pkschl = 'YCOM' and r5 = 'X'.
        write: /1 'CUSTOMER', 12 'DIST.C', 20 'MATERIAL'.
        write: 56 'COMM PERC'.
        write: 70 'VALID FROM', 83 'VALID TO'.
        write: 96 'CREATED BY', 109 'CREATE DATE'.
      endif.
      if pkschl = 'PB01'.
        write: /1 'CUSTOMER', 12 'MATERIAL'.
        write: 48 'PRICE', 55 'CURR', 64 'UNIT'.
        write: 72 'VALID FROM', 85 'VALID TO'.
        write: 96 'CREATED BY', 109 'CREATE DATE'.
      endif.
    M02 end
    *write /0(90) SY-ULINE.                                       "M02
      write /0(132) SY-ULINE.                                   "M02
          FORM GET_DISPLAY_AMOUNT                                       *
    form get_display_amount.
      CALL FUNCTION 'CURRENCY_AMOUNT_SAP_TO_DISPLAY'
           EXPORTING
                CURRENCY        = i_inforec-konwa
                AMOUNT_INTERNAL = tamt
           IMPORTING
                AMOUNT_DISPLAY  = jpy_amt.
                EXCEPTIONS
                     INTERNAL_ERROR  = 1
                     OTHERS          = 2.
    endform.

    Hi Srinivas
    Based on the radiobutton selections i want to get the data.In the SELECTION-SCREEN iam using one radio button and one parameter( which holds the date).According to the date i have to get the data.This parameter iam using in select statement.
    if i select another radio button ( with select-options)
    i have to get the data with range...
    pls go through this
    SELECTION-SCREEN BEGIN OF BLOCK test WITH FRAME TITLE TEXT-004.
      SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(25) text-005.
        PARAMETERS: r6 RADIOBUTTON GROUP xyz.
        SELECTION-SCREEN POSITION 33.
        PARAMETERS: Pvalid TYPE d default sy-datum.
      SELECTION-SCREEN END OF LINE.
      SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(25) text-006.
        PARAMETERS: r7 RADIOBUTTON GROUP xyz.
        SELECTION-SCREEN POSITION 30.
      select-options prange for sy-datum.
      SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK test.
    select vtweg matnr knumh datbi datab                   
                        into corresponding fields of i_inforec
                        from A004
                        where kappl eq 'V'
                        and kschl eq pkschl
                        and vkorg eq pvkorg
                       and vtweg in svtweg
                       and matnr in smatnr
                       and datbi ge pvalid "this is parameter
                       and datab le pvalid "this is parameter
                       and datab ge prange-low "range  
                       and datbi le prange-high."range  
    Ravi

  • Get old and new values from DBTABLOG table

    Hi,
    I am developing a report to display all changes to some fields of PKHD table over a date range. CDHDR & CDPOS do not capture the changes while DBTABLOG does. But the variable key field (LOGDATA) in DBTABLOG does hold encrypted values which need to be decrypted. Is there any FM or a way out to get them ?
    Please let me know. Thanks a lot.
    Regards
    Neeraj

    Use DBLOG_READ and then work with the data like in the following sample
    * Constants (cf. SAP RSVTPTOP)
      CONSTANTS: type_i4 LIKE x031l-fieldtype VALUE 'AC',       "UF160698B
                 type_i2 LIKE x031l-fieldtype VALUE 'A8',
                 type_f  LIKE x031l-fieldtype VALUE '88'.       "UF160698E
    * First - informations from directory
            REFRESH fld_list.
            CALL FUNCTION 'GET_FIELDTAB'
              EXPORTING
                langu                     = sy-langu
                only                      = ' '
                tabname                   = 'TEVEN'
                withtext                  = 'X'
    *       IMPORTING
    *         HEADER                      =
    *         RC                        =
              TABLES
                fieldtab                  = fld_list
              EXCEPTIONS
                internal_error            = 1
                no_texts_found            = 2
                table_has_no_fields       = 3
                table_not_activ           = 4
                OTHERS                    = 5.
            LOOP AT fld_list INTO fld WHERE keyflag = 'X'.
              ADD fld-intlen TO keylen.
            ENDLOOP.
    * Then extract data log
            REFRESH obj_list.
            obj-tab = 'TEVEN'.
            INSERT obj INTO  TABLE obj_list.
            CALL FUNCTION 'DBLOG_READ'
              EXPORTING
                from_day                   = s-aedtm-low
    *           FROM_TIME                  = '000000'
                to_day                     = s-aedtm-high
    *           TO_TIME                    = '235959'
                obj_list                   = obj_list
    *         ACCESS_DATABASE            = 'X'
    *         ACCESS_ARCHIVES            = ' '
    *         AUTO_ARCH_SEL              = ' '
    *         USER_LIST                  =
              CHANGING
                log_list                   = log_list
              EXCEPTIONS
                archive_access_error       = 1
                no_archives_found          = 2
                OTHERS                     = 3.
    *   Extract data from returned tables
            LOOP AT log_list INTO log.
              LOOP AT fld_list INTO fld.
                IF fld-keyflag = 'X'.
                  ASSIGN log-logkey+fld-offset(fld-intlen)
                    TO <hexa> TYPE 'X'.
                ELSE.
                  fld-offset = fld-offset - keylen.
                  ASSIGN log-logdata+fld-offset(fld-intlen)
                    TO <hexa> TYPE 'X'.
                  fld-offset = fld-offset + keylen.
                ENDIF.
                CASE fld-inttype.
                  WHEN 's'.
                    f_type = type_i2.
                  WHEN 'I'.
                    f_type = type_i4.
                  WHEN 'F'.
                    f_type = type_f.
                ENDCASE.
                IF 'sIF' CS fld-inttype.
                  feld = <hexa>.
                  CALL FUNCTION 'DB_CONVERT_FIELD_TO_HOST'
                       EXPORTING
                            type        = f_type
                       CHANGING
                            field       = feld
                       EXCEPTIONS
                            wrong_param = 1
                            OTHERS      = 2.
                  ASSIGN feld TO <hexa> TYPE 'X'.
                ENDIF.
                ASSIGN <hexa> TO <char> TYPE 'C'.
                teven+fld-offset(fld-intlen) = <char>.
              ENDLOOP.
    *     Here structure teven is filled
            ENDLOOP.
    Regards

  • Logic needed Pls help

    Hi
    I have to add 'Upload excel file' option in Material consumption program. Current logic is Uploading Unix file. Can any one give me some idea pls.
    following is my coding
    PROGRAM ZMDM0081 MESSAGE-ID ZM.
    TABLES: MARA.
    * Resource file record structure
    DATA: BEGIN OF RECORD,
            MATERIAL_NUMBER(10),
            PLANT(5),
            CORRECTED_VALUE_19(11),
            CORRECTED_VALUE_18(11),
            CORRECTED_VALUE_17(11),
            CORRECTED_VALUE_16(11),
            CORRECTED_VALUE_15(11),
            CORRECTED_VALUE_14(11),
            CORRECTED_VALUE_13(11),
            CORRECTED_VALUE_12(11),
            CORRECTED_VALUE_11(11),
            CORRECTED_VALUE_10(11),
            CORRECTED_VALUE_09(11),
            CORRECTED_VALUE_08(11),
            CORRECTED_VALUE_07(11),
            CORRECTED_VALUE_06(11),
            CORRECTED_VALUE_05(11),
            CORRECTED_VALUE_04(11),
            CORRECTED_VALUE_03(11),
            CORRECTED_VALUE_02(11),
            CORRECTED_VALUE_01(11),
          END OF RECORD.
    * Working variables
    DATA: RECORD_READ(6)   TYPE P,
          RECORD_INSERT(6) TYPE P,
          RECORD_OMIT(6)   TYPE P,
          MATERIAL_NUMBER  LIKE MARA-MATNR,
          G_BRGEW          LIKE MARA-BRGEW,
          N_NTGEW          LIKE MARA-NTGEW,
          PLANT            LIKE MARC-WERKS,
          REMARKS(50),
          FLAG(1),
          RECORD_FLAG(1),
          INTENSIFIED_FLAG(1),
          NUMBER(6)        TYPE P.
    * Constant variables
    CONSTANTS: VALID   VALUE '1',
               INVALID VALUE '0',
               ON      VALUE '1',
               OFF     VALUE '0'.
    * Reporting groups
    FIELD-GROUPS HEADER.
    * Insert into groups
    INSERT MATERIAL_NUMBER
           PLANT
           REMARKS
           INTO HEADER.
    * BDC parameters
    SELECTION-SCREEN BEGIN OF BLOCK ONE WITH FRAME TITLE TEXT-010.
    PARAMETERS: FILE(30) TYPE C
                          DEFAULT '/export/remote/data.txt'
                          LOWER CASE
                          OBLIGATORY,
                 SESSION  LIKE RL04I-MAPPE
                          OBLIGATORY
                          DEFAULT '8301_MM02',
                          UNAME LIKE SY-UNAME DEFAULT SY-UNAME.
    SELECTION-SCREEN END OF BLOCK ONE.
    * Data conversion parameters
    SELECTION-SCREEN BEGIN OF BLOCK TWO WITH FRAME TITLE TEXT-020.
    PARAMETERS MONTH(2) TYPE N DEFAULT 1.
    SELECTION-SCREEN END OF BLOCK TWO.
    * Notes to user
    SELECTION-SCREEN BEGIN OF BLOCK THREE WITH FRAME TITLE TEXT-030.
    SELECTION-SCREEN COMMENT /5(70) TEXT-040.
    SELECTION-SCREEN COMMENT /5(70) TEXT-050.
    SELECTION-SCREEN END OF BLOCK THREE.
    MOVE UNAME TO SY-UNAME.
    * Including SAP R/3 BDC customized include
    INCLUDE ZSIN0001.
    * Verifying the path & file name
    AT SELECTION-SCREEN ON FILE.
      PERFORM RESOURCE_FILE_OPEN.
    * Processing BDC
    START-OF-SELECTION.
      PERFORM SESSION_OPEN.
      PERFORM SESSION_GENERATION.
      PERFORM SESSION_CLOSE.
      CLOSE DATASET FILE.
    * Printing execution report
    END-OF-SELECTION.
      SKIP.
      WRITE  /15 'BDC & SYSTEM PARAMETERS -' COLOR 3.
      SKIP.
      WRITE: /15 'Resource path & filename ..........', FILE,
             /15 'Session name ......................', SESSION,
             /15 'ABAP/4 Program name ...............', SY-REPID,
             /15 'Client ............................', SY-MANDT,
             /15 'SAP System ID .....................', SY-SYSID,
             /15 'SAP Release .......................', SY-SAPRL,
             /15 'Host ..............................', SY-HOST,
             /15 'Operating system ..................', SY-OPSYS,
             /15 'Database system ...................', SY-DBSYS,
             /15 'User ID ...........................', SY-UNAME,
             /15 'Date ..............................', SY-DATUM,
             /15 'Time ..............................', SY-UZEIT.
      SKIP 3.
      WRITE  /15 'DATA CONVERSION DEFAULT PARAMETERS -' COLOR 3.
      SKIP.
      WRITE: /15 'Start at previous month ............', MONTH.
      SKIP 3.
      WRITE  /15 'EXECUTION REPORT -' COLOR 3.
      SKIP.
      WRITE: /15 'Total records read form file ......', RECORD_READ,
             /15 'Total records insert to BDC .......', RECORD_INSERT,
             /15 'Total records omitted .............', RECORD_OMIT.
      NEW-PAGE.
      SORT.
      LOOP.
        ADD 1 TO NUMBER.
        IF INTENSIFIED_FLAG EQ ON.
          FORMAT COLOR 2 INTENSIFIED ON.
          MOVE OFF TO INTENSIFIED_FLAG.
        ELSE.
          FORMAT COLOR 2 INTENSIFIED OFF.
          MOVE ON TO INTENSIFIED_FLAG.
        ENDIF.
        WRITE: /1 NUMBER, MATERIAL_NUMBER, PLANT, REMARKS.
        POSITION SY-LINSZ.
        WRITE ' '.
      ENDLOOP.
    * Reading resource file and generating BDC session
    FORM SESSION_GENERATION.
      DO.
        READ DATASET FILE INTO RECORD.
        IF SY-SUBRC NE 0 OR RECORD IS INITIAL.
          EXIT.
        ENDIF.
        ADD 1 TO RECORD_READ.
        PERFORM RECORD_CONDENSATION.
        PERFORM RECORD_VERIFICATION.
        CHECK RECORD_FLAG EQ VALID.
        REFRESH BDCDATA.
        PERFORM SCREEN_SEQUENCE.
        PERFORM BDC_TRANSACTION USING 'MM02'.
        IF SY-SUBRC EQ 0 .
          ADD 1 TO RECORD_INSERT.
        ELSE.
          ADD 1 TO RECORD_OMIT.
        ENDIF.
      ENDDO.
    ENDFORM.                    "SESSION_GENERATION
    * Condensing the record fields
    FORM RECORD_CONDENSATION.
      CONDENSE: RECORD-MATERIAL_NUMBER,
                RECORD-PLANT,
                RECORD-CORRECTED_VALUE_19,
                RECORD-CORRECTED_VALUE_18,
                RECORD-CORRECTED_VALUE_17,
                RECORD-CORRECTED_VALUE_16,
                RECORD-CORRECTED_VALUE_15,
                RECORD-CORRECTED_VALUE_14,
                RECORD-CORRECTED_VALUE_13,
                RECORD-CORRECTED_VALUE_12,
                RECORD-CORRECTED_VALUE_11,
                RECORD-CORRECTED_VALUE_10,
                RECORD-CORRECTED_VALUE_09,
                RECORD-CORRECTED_VALUE_08,
                RECORD-CORRECTED_VALUE_07,
                RECORD-CORRECTED_VALUE_06,
                RECORD-CORRECTED_VALUE_05,
                RECORD-CORRECTED_VALUE_04,
                RECORD-CORRECTED_VALUE_03,
                RECORD-CORRECTED_VALUE_02,
                RECORD-CORRECTED_VALUE_01.
    ENDFORM.                    "RECORD_CONDENSATION
    * Verifying record fields
    FORM RECORD_VERIFICATION.
      MOVE VALID TO RECORD_FLAG.
      UNPACK RECORD-MATERIAL_NUMBER TO MATERIAL_NUMBER.
      SELECT SINGLE * FROM MARA
                          WHERE MATNR EQ MATERIAL_NUMBER.
      IF SY-SUBRC NE 0.
        ADD 1 TO RECORD_OMIT.
        MOVE: RECORD-PLANT TO PLANT,
              TEXT-060     TO REMARKS,
              INVALID      TO RECORD_FLAG.
        EXTRACT HEADER.
        EXIT.
      ELSE.
        IF MARA-NTGEW > MARA-BRGEW.     "add to check for net weight > grow
          MOVE '1' TO FLAG.
        ELSE.
          MOVE ' ' TO FLAG.
        ENDIF.
      ENDIF.
      MOVE RECORD-PLANT TO PLANT.
      SELECT SINGLE MATNR WERKS INTO  (PLANT, MATERIAL_NUMBER)
                                FROM  ('MARC')
                                WHERE MATNR EQ MATERIAL_NUMBER
                                AND   WERKS EQ PLANT.
      IF SY-SUBRC NE 0.
        ADD 1 TO RECORD_OMIT.
        MOVE: TEXT-070 TO REMARKS,
              INVALID  TO RECORD_FLAG.
        EXTRACT HEADER.
      ENDIF.
    ENDFORM.                    "RECORD_VERIFICATION
    * Performing the screen sequence
    FORM SCREEN_SEQUENCE.
      PERFORM SCREEN_SAPLMGMM_0060.
      PERFORM SCREEN_SAPLMGMM_0070.
      PERFORM SCREEN_SAPLMGMM_3005.
      PERFORM SCREEN_SAPLMGMM_0081.
      PERFORM SCREEN_SAPLMGMM_3006.
      PERFORM SCREEN_SAPLMGMM_3110.
    ENDFORM.                    "SCREEN_SEQUENCE
    * Change Material: Initial Screen
    FORM SCREEN_SAPLMGMM_0060.
      PERFORM BDC_DYNPRO USING 'SAPLMGMM'   '0060'.
      PERFORM BDC_FIELD  USING 'RMMG1-MATNR' RECORD-MATERIAL_NUMBER.
      PERFORM BDC_FIELD  USING 'BDC_OKCODE'  '/5'. " Select view(s)
    ENDFORM.                    "SCREEN_SAPLMGMM_0060
    * Select view(s)
    FORM SCREEN_SAPLMGMM_0070.
      PERFORM BDC_DYNPRO USING 'SAPLMGMM'            '0070'.
      PERFORM BDC_FIELD  USING 'MSICHTAUSW-KZSEL(01)' 'X'.
      PERFORM BDC_FIELD  USING 'BDC_OKCODE'           '/0'. " Enter
    ENDFORM.                    "SCREEN_SAPLMGMM_0070
    * Change Material: Basic data
    FORM SCREEN_SAPLMGMM_3005.
      PERFORM BDC_DYNPRO USING 'SAPLMGMM'   '3005'.
      PERFORM BDC_FIELD  USING 'BDC_OKCODE' 'SP08'.             " MRP 1
      IF FLAG EQ '1'.
        PERFORM BDC_DYNPRO USING 'SAPLMGMM'   '3005'.
        PERFORM BDC_FIELD  USING 'BDC_OKCODE'           '/0'.
      ENDIF.
    ENDFORM.                    "SCREEN_SAPLMGMM_3005
    * Organizational levels
    FORM SCREEN_SAPLMGMM_0081.
      PERFORM BDC_DYNPRO USING 'SAPLMGMM'    '0081'.
      PERFORM BDC_FIELD  USING 'RMMG1-WERKS' RECORD-PLANT.
      PERFORM BDC_FIELD  USING 'BDC_OKCODE'  '=ENTR'.  "Continue
    ENDFORM.                    "SCREEN_SAPLMGMM_0081
    * Change Material: MRP 1
    FORM SCREEN_SAPLMGMM_3006.
      PERFORM BDC_DYNPRO USING 'SAPLMGMM'   '3006'.
      PERFORM BDC_FIELD  USING 'BDC_OKCODE' 'ZU11'. " Consumption
    ENDFORM.                    "SCREEN_SAPLMGMM_3006
    * Change Material: Consumption
    FORM SCREEN_SAPLMGMM_3110.
      CONSTANTS: PREVIOUS_MONTH VALUE 'X',
                 THIS_MONTH     VALUE ' '.
      DATA: ROW_POSITION(2)      TYPE N VALUE 0,
            WS_POSITION(2)       TYPE C,
            FIELDNAME            LIKE BDCDATA-FNAM,
            CONSUMPTION_QUANTITY LIKE RECORD-CORRECTED_VALUE_01.
      PERFORM BDC_DYNPRO USING 'SAPLMGMM' '3110'.
    *  if month eq previous_month.
    *    move 1 to row_position.
    *  elseif month eq this_month.
    *    move 0 to row_position.
    *  endif.
      MOVE MONTH TO ROW_POSITION.
      DO 19 TIMES VARYING CONSUMPTION_QUANTITY
                  FROM RECORD-CORRECTED_VALUE_01
                  NEXT RECORD-CORRECTED_VALUE_02.
        IF ROW_POSITION GT 11.
          MOVE 1 TO ROW_POSITION.
          PERFORM BDC_FIELD  USING 'BDC_OKCODE' 'VWNP'. " Page down
          PERFORM BDC_DYNPRO USING 'SAPLMGMM'   '3110'.
        ENDIF.
        UNPACK ROW_POSITION TO WS_POSITION.
        CONCATENATE 'RM03M-VBWRT(' WS_POSITION ')' INTO FIELDNAME.
        IF CONSUMPTION_QUANTITY+0(1) EQ '-'.
          SHIFT CONSUMPTION_QUANTITY LEFT BY 1 PLACES.
          CONCATENATE CONSUMPTION_QUANTITY '-' INTO CONSUMPTION_QUANTITY.
        ENDIF.
        PERFORM BDC_FIELD USING FIELDNAME CONSUMPTION_QUANTITY.
        ADD 1 TO ROW_POSITION.
      ENDDO.
      PERFORM BDC_DYNPRO USING 'SAPLMGMM' '3110'.
      PERFORM BDC_FIELD  USING 'BDC_OKCODE' '/11'. " Save
    ENDFORM.                    "SCREEN_SAPLMGMM_3110
    Include Program
    * BDC data table and record structure defination
    DATA BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
    * Opening a resource file
    FORM RESOURCE_FILE_OPEN.
      DATA ERROR_MESSAGE(40).
    *Begin of changes Mod01
    *  OPEN DATASET FILE FOR INPUT IN TEXT MODE MESSAGE ERROR_MESSAGE.
      OPEN DATASET FILE FOR INPUT IN TEXT MODE ENCODING DEFAULT MESSAGE
                                                          ERROR_MESSAGE.
    *End of changes Mod01
      IF SY-SUBRC NE 0.
        MESSAGE E000 WITH FILE ERROR_MESSAGE.
      ENDIF.
    ENDFORM.
    * Opening of BDC session
    FORM SESSION_OPEN.
      CALL FUNCTION 'BDC_OPEN_GROUP'
           EXPORTING  CLIENT              = SY-MANDT
                      DEST                = SY-HOST
                      GROUP               = SESSION
                      USER                = SY-UNAME
                      KEEP                = 'X'
           EXCEPTIONS CLIENT_INVALID      = 01
                      DESTINATION_INVALID = 02
                      GROUP_INVALID       = 03
                      HOLDDATE_INVALID    = 04
                      INTERNAL_ERROR      = 05
                      QUEUE_ERROR         = 06
                      RUNNING             = 07
                      USER_INVALID        = 08.
      CASE SY-SUBRC.
        WHEN 01. MESSAGE E001 WITH SY-MANDT.
        WHEN 02. MESSAGE E002.
        WHEN 03. MESSAGE E003.
        WHEN 04. MESSAGE E004.
        WHEN 05. MESSAGE E005.
        WHEN 06. MESSAGE E006.
        WHEN 07. MESSAGE E007.
        WHEN 08. MESSAGE E007.
      ENDCASE.
    ENDFORM.
    * Closing BDC session
    FORM SESSION_CLOSE.
      CALL FUNCTION 'BDC_CLOSE_GROUP'
        EXCEPTIONS NOT_OPEN    = 01
                   QUEUE_ERROR = 02.
      CASE SY-SUBRC.
        WHEN 01. MESSAGE E009.
        WHEN 02. MESSAGE E010.
      ENDCASE.
    ENDFORM.
    * Inserting data into BDC
    FORM BDC_TRANSACTION USING TRANSACTION_CODE.
      CALL FUNCTION 'BDC_INSERT'
           EXPORTING  TCODE          = TRANSACTION_CODE
           TABLES     DYNPROTAB      = BDCDATA
           EXCEPTIONS INTERNAL_ERROR = 1
                      NOT_OPEN       = 2
                      QUEUE_ERROR    = 3
                      TCODE_INVALID  = 4
                      OTHERS         = 5.
    ENDFORM.
    * Insert program name & screen number
    FORM BDC_DYNPRO USING PROGRAM DYNPRO.
      CLEAR BDCDATA.
      MOVE: PROGRAM TO BDCDATA-PROGRAM,
            DYNPRO  TO BDCDATA-DYNPRO,
            'X'     TO BDCDATA-DYNBEGIN.
      APPEND BDCDATA.
    ENDFORM.
    * Inserting field name/BDC_OKCODE/BDC_CUESOR and value
    FORM BDC_FIELD USING FNAM FVAL.
      CLEAR BDCDATA.
      MOVE: FNAM TO BDCDATA-FNAM,
            FVAL TO BDCDATA-FVAL.
      APPEND BDCDATA.
    ENDFORM.

    i have changed the selection screen as follows
    SELECTION-SCREEN BEGIN OF BLOCK one WITH FRAME TITLE text-010.
    *                                                          "1)
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS p_unix RADIOBUTTON GROUP rad1 .                 "
    SELECTION-SCREEN COMMENT 5(26) text-008.
    SELECTION-SCREEN POSITION 33.                              "
    PARAMETERS: file(128) TYPE c
                          DEFAULT '/export/remote/data.txt' LOWER CASE.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS p_xls RADIOBUTTON GROUP rad1 .                 "excel file
    SELECTION-SCREEN COMMENT 5(26) text-009.
    SELECTION-SCREEN POSITION 33.                              "
    PARAMETERS: filf(128).
    SELECTION-SCREEN END OF LINE.
    *>>
    *PARAMETERS: file(128) TYPE c
    *                      DEFAULT '/export/remote/data.txt' LOWER CASE OBLIGATORY,
    PARAMETERS:  session  LIKE rl04i-mappe OBLIGATORY
                          DEFAULT '8301_MM02',
                 uname LIKE sy-uname DEFAULT sy-uname.
    SELECTION-SCREEN END OF BLOCK one.
    * Data conversion parameters
    SELECTION-SCREEN BEGIN OF BLOCK two WITH FRAME TITLE text-020.
    PARAMETERS month(2) TYPE n DEFAULT 1.
    SELECTION-SCREEN END OF BLOCK two.
    * Notes to user
    SELECTION-SCREEN BEGIN OF BLOCK three WITH FRAME TITLE text-030.
    SELECTION-SCREEN COMMENT /5(70) text-040.
    SELECTION-SCREEN COMMENT /5(70) text-050.
    SELECTION-SCREEN END OF BLOCK three.

  • Select a specific view in MM02/MM01

    Hi Abappers,
    I am doing a BDC on MM01 transaction and want to just select the accounting view and extend materials for different valuation types. But the position of accounting view is coming different on different material and my BDC recording is failing to select the accounting view. Does anyone has any idea how we can pinpoint and select the accounting view?
    Thanks,
    David.

    SELECTION_VIEWS_FIND  - This FM Will work depends on material type..
    in your case this FM Is not required and you need to have Accounting view.
    Any way See below program and you will get some idea and uploaded data into Material master change mode and it is applicable to user defined view
    REPORT zjpmuim306 NO STANDARD PAGE HEADING LINE-SIZE 250 MESSAGE-ID
    zjpm001.
    *&   I N B O U N D  V I A   A B A P : Batch input Session method     *
    *&   Development ID: IM_DD_306_LJP                                   *
    *&   Report        : ZJPMUIM306                                      *
    *&   The Purpose of the Object is to interface Create Input Record   *
    *&   for SAP Migration from the Material master of BPCS All the      *
    *&   information received at BPCS is collected into a single record. *
    *&   By using session method upload data from file ,one item is
    *&   created for one record                                          *
    *&   Change Log:                                                     *
    *&   Init       Who              Date         Text                   *
    *&  MALIKDH1   Seshu Reddy    26-07-2003   Initial Version           *
                             Constants                                   *
    CONSTANTS:c_vkorg(4) type c value 'JP20',        " Sales Organization
              c_vtweg(2) type c value 'TR' ,         " Distribution Channel
              c_werks(4) Type c value 'JP01' ,       " Plant
              c_viewlist(15) VALUE 'KDEALBSZXVPCFQG'," View list
              c_scm_view TYPE msichtausw-dytxt VALUE 'SCM View',
              c_sd_view TYPE msichtausw-dytxt VALUE 'SD View',
              c_seq_code(2) VALUE 'Z1',              " Sequential Code
              c_keep(1) TYPE c VALUE  'X',           " Keep
              c_group LIKE apqi-groupid VALUE 'IM306', " Session Name
              c_tcode  LIKE tstc-tcode VALUE 'MM02',  " Transaction Code
              c_blank(1) VALUE ' ',                   " Blank
              c_intls(1) VALUE 'N'.                  " Logistic Status
                  Variables                                      *
    DATA: g_flag1(1),  " Variable to hold
          g_flag(1),   " Variable to hold
          g_file LIKE rlgrap-filename VALUE
         'C:\Documents and Settings\seshur\Desktop\HCLT123.CSV'. " File name
           Internal tables/ Work area                           *
    Internal Table for Delimter
    DATA : BEGIN OF t_delim OCCURS 0,
           text(1000),
           END OF t_delim.
    Internal table for BDC processing
    DATA : t_bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
    Internal table for holding the data which has to be uploaded.
    DATA: BEGIN OF t_bpcs OCCURS 0,
          matnr(15) TYPE c,  " material no
          dosage(40) TYPE c, " Dosage form(Local)
          appearance(40) TYPE c, " Appearance
          idcode(6) TYPE c,     " Identification Code
          prostformno(10) TYPE c, "SOP
          weitab(7) TYPE c,    " Weight/tablet
          uom1(2) TYPE c,     " UOM of Carton
          uom2(2) TYPE c,     " UOM of Case
          carsize(14) TYPE c, " Carton size
          cassize(14) TYPE c, " Case size
          rupqty(11) TYPE c,  " Round up
          abvname(3) TYPE c,  " Product short name
          END OF t_bpcs.
    *Internal table for t_bpcs
    DATA: BEGIN OF t_mdata OCCURS 0,
          matnr  LIKE marc-matnr, " Material number
          zzjp_dos_frm LIKE marc-zzjp_dos_frm, " Dosage form(Local)
          zzjp_aprn LIKE marc-zzjp_aprn, " Appearance
          zzjp_con_id LIKE marc-zzjp_con_id," Identification Code
          zzjp_nyu_sop LIKE marc-zzjp_nyu_sop,"SOP
          zzjp_wei_tab(10) type c , " Weight/tablet
          zzjp_bio  LIKE marc-zzjp_bio,"Biologics Indicator
          zzjp_itf LIKE marc-zzjp_itf, " ITF code
          zzjp_car(2) type c, " UOM of Carton
          zzjp_cas(2) type c, " UOM of Case
          zzjp_car_size(11) type c," Carton size
          zzjp_cas_size(11) type c, " Case size
          zzjp_rupqty(11) type c,  " Round up
          zzjp_init_ls LIKE marc-zzjp_init_ls, " Logistic Status
          zzjp_re1 LIKE marc-zzjp_re1, "Document type(Local)
          zzjp_re2 LIKE marc-zzjp_re2, "Report type
          zzjp_re3 LIKE marc-zzjp_re3, "Shipping report type
          zzjp_pro_id LIKE mvke-zzjp_pro_id," Product output sequence
          zzjp_bu_id LIKE mvke-zzjp_bu_id, " Business unit indicator
          zzjp_abv_name LIKE mvke-zzjp_abv_name," Product short name
          zzjp_abv_id1 LIKE mvke-zzjp_abv_id1," Product short name output
          zzjp_abv_id2 LIKE mvke-zzjp_abv_id2," Product short name internal
          zzjp_spl_id LIKE mvke-zzjp_spl_id,  " Sample internal order
          END OF t_mdata.
    Internal table for Mara Table
    DATA: BEGIN OF t_mara OCCURS 0,
          matnr LIKE mara-matnr,  " material Number
          vpsta LIKE mara-vpsta,  " Maintenance status of complete material
          pstat like mara-pstat,  " Maintenance status
          END OF t_mara.
    Internal table for Material Master View Selection Screens
    DATA: BEGIN OF t_bildtab OCCURS 0.
            INCLUDE STRUCTURE mbildtab.
    DATA: END OF t_bildtab.
    internal table for T_bildtab
    DATA: t_bildtab_dup LIKE t_bildtab OCCURS 0 WITH HEADER LINE.
    *Work area for T_bildtab internal table(Views Selection)
    DATA: BEGIN OF w_data,
          flag1 type c,
          anzd70 TYPE i,
          field1(20) type c,
          field2(20) type c,
          field3(20) type c,
          field4(20) type c,
          count(2) TYPE c,
          END OF w_data.
                Main Processing                           *
    START-OF-SELECTION.
    Store data from file into internal table
      PERFORM f_uplaod_data.
    Transfer the uploaded data into t_mdata internal Table
      PERFORM f_process_data.
    Selecting The views based on Material number
      PERFORM f_view_list.
    Open a BDC Session
      PERFORM f_bdc_open.
    *Selecting the fields from mara table
      SELECT matnr
             vpsta
             pstat
        FROM mara
      INTO TABLE t_mara
      FOR ALL ENTRIES IN t_mdata
      WHERE matnr = t_mdata-matnr.
      SORT t_mara BY matnr.
      SORT t_mdata BY matnr.
    Transfer the uploaded data into BDCDATA structure
      PERFORM f_process_bdc.
    Close The BDC Session
      PERFORM f_close_group.
    *&      Form  F_VIEW_LIST                                             *
             Routine to used for Calling the function module            *
              Selection_views_find                                      *
    FORM f_view_list.
      CALL FUNCTION 'SELECTION_VIEWS_FIND'
           EXPORTING
                bildsequenz     = c_seq_code
                pflegestatus    = c_viewlist
           TABLES
                bildtab         = t_bildtab
           EXCEPTIONS
                call_wrong      = 1
                empty_selection = 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.                    " F_VIEW_LIST
    *&      Form  f612_view_sort                                          *
      Routine to used for Selecting The views based on Material Number  *
    FORM f612_view_sort.
      t_bildtab_dup[] = t_bildtab[].
    Reading the Internal table t_mara
      READ TABLE t_mara WITH KEY matnr = t_mdata-matnr.
      TRANSLATE t_mara-pstat USING ' $'.
      CLEAR: w_data-flag1, w_data-anzd70.
      LOOP AT t_bildtab_dup.
        IF t_bildtab_dup-pstat CA t_mara-pstat.
          w_data-anzd70 = w_data-anzd70 + 1.
          IF t_bildtab_dup-kzanz IS INITIAL.
            t_bildtab_dup-kzanz = 'X'.
            w_data-flag1 = 'X'.
            MODIFY t_bildtab_dup.
          ENDIF.
        ELSE.
          IF NOT t_bildtab_dup-kzanz IS INITIAL.
            CLEAR t_bildtab_dup-kzanz.
            w_data-flag1 = 'X'.
            MODIFY t_bildtab_dup.
          ENDIF.
        ENDIF.
      ENDLOOP.
      TRANSLATE t_mara-pstat USING '$ '.
      IF NOT w_data-flag1 IS INITIAL.
        SORT t_bildtab_dup BY kzanz DESCENDING idxbd ASCENDING.
      ENDIF.
    *Reading The internal table for T_bildtab_dup
      READ TABLE t_bildtab_dup WITH KEY dytxt = c_scm_view.
      IF t_bildtab_dup-kzanz = 'X'.
        WRITE sy-tabix TO w_data-count.
        w_data-count = w_data-count + 2.
        IF w_data-anzd70 > 18.
          w_data-count = w_data-count - 18.
        ENDIF.
        CONCATENATE 'MSICHTAUSW-DYTXT(' w_data-count ')' INTO w_data-field1.
        CONCATENATE 'MSICHTAUSW-KZSEL(' w_data-count ')' INTO w_data-field2.
      ENDIF.
      READ TABLE t_bildtab_dup WITH KEY dytxt = c_sd_view.
      IF t_bildtab_dup-kzanz = 'X'.
        WRITE sy-tabix TO w_data-count.
        IF w_data-anzd70 > 18.
              w_data-count = w_data-count + 2.
          w_data-count = w_data-count - 18.
        ENDIF.
        CONCATENATE 'MSICHTAUSW-DYTXT(' w_data-count ')' INTO w_data-field3.
        CONCATENATE 'MSICHTAUSW-KZSEL(' w_data-count ')' INTO w_data-field4.
      ENDIF.
    ENDFORM.                    " f612_view_sort
    *&      Form  f_uplaod_data                                           *
    Routine to used for Uploading the data from file to Internal table *
    FORM f_uplaod_data.
      CALL FUNCTION 'WS_UPLOAD'
           EXPORTING
                filename                = g_file
                filetype                = 'DAT'
           TABLES
                data_tab                = t_delim
           EXCEPTIONS
                conversion_error        = 1
                file_open_error         = 2
                file_read_error         = 3
                invalid_type            = 4
                no_batch                = 5
                unknown_error           = 6
                invalid_table_width     = 7
                gui_refuse_filetransfer = 8
                customer_error          = 9
                OTHERS                  = 10.
      IF sy-subrc <> 0.
             MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      IF t_bpcs IS INITIAL.
        LOOP AT t_delim.
          SPLIT t_delim-text AT ',' INTO t_bpcs-matnr
                                         t_bpcs-dosage
                                         t_bpcs-appearance
                                         t_bpcs-idcode
                                         t_bpcs-prostformno
                                         t_bpcs-weitab
                                         t_bpcs-uom1
                                         t_bpcs-uom2
                                         t_bpcs-carsize
                                         t_bpcs-cassize
                                         t_bpcs-rupqty
                                         t_bpcs-abvname.
          APPEND t_bpcs.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    " f_uplaod_data
    *&      Form  F_BDC_OPEN
          Routine  to create BDC Session to be processed
    FORM f_bdc_open.
      CALL FUNCTION 'BDC_OPEN_GROUP'
           EXPORTING
                client              = sy-mandt
                group               = c_group
                keep                = c_keep
                user                = sy-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 ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ELSE.
      MESSAGE S000 WITH 'Batch input session is created successfully'(T02).
      ENDIF.
    ENDFORM.                    " F_BDC_OPEN
    *&      Form  F_PROCESS_BDC
          Processing of BDCDATA Structure
    FORM f_process_bdc.
      LOOP AT t_mdata.
        PERFORM f612_view_sort.
        PERFORM f_bdc_dynpro USING 'SAPLMGMM' '0060'.
        PERFORM f_bdc_field USING 'BDC_CURSOR'
                                      'RMMG1-MATNR'.
        PERFORM f_bdc_field USING 'BDC_OKCODE'
                                      '=AUSW'.
        PERFORM f_bdc_field USING 'RMMG1-MATNR'
                                      t_mdata-matnr.
        PERFORM f_bdc_dynpro USING 'SAPLMGMM' '0070'.
        PERFORM f_bdc_field USING 'BDC_CURSOR'
                                  'MSICHTAUSW-DYTXT(01)'.
        IF w_data-anzd70 > 18.
          PERFORM f_bdc_field       USING 'BDC_OKCODE'
                                      '=P+'.
          PERFORM f_bdc_dynpro      USING 'SAPLMGMM' '0070'.
          PERFORM f_bdc_field  USING 'BDC_OKCODE' '/00'.
        ENDIF.
    reading the t_bildtab internal table
        READ TABLE t_bildtab_dup WITH KEY dytxt = c_scm_view.
        IF t_bildtab_dup-kzanz = 'X'.
          PERFORM f_bdc_field       USING 'BDC_CURSOR'
                                        w_data-field1.
          PERFORM f_bdc_field       USING w_data-field2 'X'.
          g_flag = 'X'.
        ENDIF.
    reading the t_bildtab internal table
        READ TABLE t_bildtab_dup WITH KEY dytxt = c_sd_view.
        IF sy-subrc EQ 0.
          g_flag = 'X'.
        ENDIF.
        IF t_bildtab_dup-kzanz = 'X'.
          PERFORM f_bdc_field       USING 'BDC_CURSOR'
                                        w_data-field3.
          PERFORM f_bdc_field       USING w_data-field4 'X'.
          g_flag1 = 'X'.
        ENDIF.
        IF g_flag = 'X' AND g_flag1 = 'X'.
          PERFORM f_bdc_dynpro      USING 'SAPLMGMM' '0080'.
          PERFORM f_bdc_field       USING 'BDC_CURSOR'
                                        'RMMG1-VTWEG'.
          PERFORM f_bdc_field       USING 'BDC_OKCODE'
                                        '=ENTR'.
          PERFORM f_bdc_field       USING 'RMMG1-WERKS'
                                        c_werks.
          PERFORM f_bdc_field       USING 'RMMG1-VKORG'
                                        c_vkorg.
          PERFORM f_bdc_field       USING 'RMMG1-VTWEG'
                                        c_vtweg.
          CLEAR g_flag.
          CLEAR g_flag1.
        ELSE.
          IF g_flag = 'X'.
            PERFORM f_bdc_dynpro      USING 'SAPLMGMM' '0080'.
            PERFORM f_bdc_field       USING 'RMMG1-WERKS'
                                        c_werks.
            PERFORM f_bdc_field      USING 'BDC_OKCODE' '/00'.
          ELSE.
            IF g_flag1 = 'X'.
              PERFORM f_bdc_dynpro      USING 'SAPLMGMM' '0080'.
              PERFORM f_bdc_field       USING 'BDC_CURSOR'
                                            'RMMG1-VTWEG'.
              PERFORM f_bdc_field       USING 'RMMG1-WERKS'
                                          c_werks.
              PERFORM f_bdc_field       USING 'RMMG1-VKORG'
                                            c_vkorg.
              PERFORM f_bdc_field       USING 'RMMG1-VTWEG'
                                            c_vtweg.
              PERFORM f_bdc_field       USING 'BDC_OKCODE'
                                             '=ENTR'.
            ENDIF.
          ENDIF.
        ENDIF.
    *Processing of SCM View
        PERFORM f_bdc_dynpro      USING 'SAPLMGMM' '4000'.
        PERFORM f_bdc_field       USING 'BDC_CURSOR' 'MARC-ZZJP_DOS_FRM'.
        PERFORM f_bdc_field       USING 'MARC-ZZJP_DOS_FRM'
                                      t_mdata-zzjp_dos_frm.
        PERFORM f_bdc_field       USING 'MARC-ZZJP_APRN'
                                      t_mdata-zzjp_aprn.
        PERFORM f_bdc_field       USING 'MARC-ZZJP_CON_ID'
                                      t_mdata-zzjp_con_id.
        PERFORM f_bdc_field       USING 'MARC-ZZJP_NYU_SOP'
                                      t_mdata-zzjp_nyu_sop.
        PERFORM f_bdc_field       USING 'MARC-ZZJP_WEI_TAB'
                                      t_mdata-zzjp_wei_tab.
        PERFORM f_bdc_field       USING 'MARC-ZZJP_CAR'
                                      t_mdata-zzjp_car.
        PERFORM f_bdc_field       USING 'MARC-ZZJP_CAS'
                                      t_mdata-zzjp_cas.
        PERFORM f_bdc_field       USING 'MARC-ZZJP_CAR_SIZE'
                                      t_mdata-ZZJP_CAR_SIZE.
        PERFORM f_bdc_field       USING 'MARC-ZZJP_CAS_SIZE'
                                      t_mdata-ZZJP_CAS_SIZE.
        PERFORM f_bdc_field       USING 'MARC-ZZJP_RUPQTY'
                                       t_mdata-ZZJP_RUPQTY.
        PERFORM f_bdc_field       USING 'MARC-ZZJP_BIO'
                                      t_mdata-zzjp_bio.
        PERFORM f_bdc_field       USING 'MARC-ZZJP_ITF'
                                      t_mdata-zzjp_itf.
        PERFORM f_bdc_field       USING 'MARC-ZZJP_INIT_LS'
                                      t_mdata-zzjp_init_ls.
        PERFORM f_bdc_field       USING 'MARC-ZZJP_RE1'
                                      t_mdata-zzjp_re1.
        PERFORM f_bdc_field       USING 'MARC-ZZJP_RE2'
                                      t_mdata-zzjp_re2.
        PERFORM f_bdc_field       USING 'MARC-ZZJP_RE3'
                                      t_mdata-zzjp_re3.
        PERFORM f_bdc_field       USING 'BDC_OKCODE'
                                      '/00'.
    *Processing of SD View
        PERFORM f_bdc_dynpro      USING 'SAPLMGMM' '4000'.
        PERFORM f_bdc_field       USING 'BDC_CURSOR' 'MVKE-ZZJP_PRO_ID'.
        PERFORM f_bdc_field       USING 'MVKE-ZZJP_PRO_ID'
                                      t_mdata-zzjp_pro_id.
        PERFORM f_bdc_field       USING 'MVKE-ZZJP_BU_ID'
                                      t_mdata-zzjp_bu_id.
        PERFORM f_bdc_field       USING 'MVKE-ZZJP_ABV_NAME'
                                      t_mdata-zzjp_abv_name.
        PERFORM f_bdc_field       USING 'MVKE-ZZJP_ABV_ID1'
                                      t_mdata-zzjp_abv_id1.
        PERFORM f_bdc_field       USING 'MVKE-ZZJP_ABV_ID2'
                                      t_mdata-zzjp_abv_id2.
        PERFORM f_bdc_field       USING 'MVKE-ZZJP_SPL_ID'
                                      t_mdata-zzjp_spl_id.
        PERFORM f_bdc_field      USING 'BDC_OKCODE' '/00'.
        PERFORM f_bdc_dynpro      USING 'SAPLSPO1' '0300'.
        PERFORM f_bdc_field       USING 'BDC_OKCODE'
                                      '=YES'.
    perform f_bdc_insert.
    REFRESH T_BDCDATA.
      ENDLOOP.
    ENDFORM.                    " F_PROCESS_BDC
    *&      Form  f_bdc_dynpro
      p_prog is the program name to which data is passed                *
      p_dyno is the screen number to which the data is passed
        Routine for populating the BDCDATA structure with the
        Screen related information
    FORM f_bdc_dynpro USING    p_prog
                               p_dyno.
      t_bdcdata-program  = p_prog.
      t_bdcdata-dynpro   = p_dyno.
      t_bdcdata-dynbegin = 'X'.
      APPEND t_bdcdata.
      CLEAR t_bdcdata.
    ENDFORM.                    " F_bdc_dynpro
    *&      Form  F_BDC_FIELD
          p_fnam is the field name to which value is passed
          p_fval is the field value which is passed
       p_fnam is the field name to which value is passed
       p_fval is the field value which is passed
    FORM f_bdc_field USING    p_fnam
                              p_fval.
      t_bdcdata-fnam = p_fnam.
      t_bdcdata-fval = p_fval.
      APPEND t_bdcdata.
      CLEAR t_bdcdata.
    ENDFORM.                    " F_bdc_field
    *&      Form  F_PROCESS_DATA                                          *
         Routine to used for moving data from T_bpcs internal table to  *
         t_mdata Internal Table                                         *
    FORM f_process_data.
      LOOP AT t_bpcs.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
             EXPORTING
                  input  = t_bpcs-matnr
             IMPORTING
                  output = t_mdata-matnr.
        MOVE t_bpcs-dosage TO t_mdata-zzjp_dos_frm.
        MOVE t_bpcs-appearance TO t_mdata-zzjp_aprn.
        MOVE t_bpcs-idcode  TO t_mdata-zzjp_con_id.
        MOVE t_bpcs-prostformno TO t_mdata-zzjp_nyu_sop.
        MOVE t_bpcs-weitab TO t_mdata-zzjp_wei_tab.
        MOVE c_blank TO t_mdata-zzjp_bio.
        MOVE c_blank TO t_mdata-zzjp_itf.
        MOVE t_bpcs-uom1 TO t_mdata-zzjp_car.
        MOVE t_bpcs-uom2 TO t_mdata-zzjp_cas.
        MOVE t_bpcs-carsize TO t_mdata-zzjp_car_size.
        MOVE t_bpcs-cassize TO t_mdata-zzjp_cas_size.
        MOVE t_bpcs-rupqty TO t_mdata-zzjp_rupqty.
        MOVE c_intls TO t_mdata-zzjp_init_ls.
        MOVE c_blank TO t_mdata-zzjp_re1.
        MOVE c_blank TO t_mdata-zzjp_re2.
        MOVE c_blank TO t_mdata-zzjp_re3.
        MOVE c_blank TO t_mdata-zzjp_pro_id.
        MOVE c_blank TO t_mdata-zzjp_bu_id.
        MOVE t_bpcs-abvname TO t_mdata-zzjp_abv_name.
        MOVE c_blank TO t_mdata-zzjp_abv_id1.
        MOVE c_blank TO t_mdata-zzjp_abv_id2.
        MOVE c_blank TO t_mdata-zzjp_spl_id.
        APPEND t_mdata.
      ENDLOOP.
    ENDFORM.                    " F_PROCESS_DATA
    *&      Form  f_bdc_close
          Routine to close the BDC Session
    FORM f_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.                    " f_close_group
    *&      Form  f_bdc_insert
         routine to input batch data into the Transaction MM02 from the
         session created
    FORM f_bdc_insert.
    CALL FUNCTION 'BDC_INSERT'
             EXPORTING
                  tcode            = c_tcode
             TABLES
                  dynprotab        = 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.                    " f_bdc_insert
    Reward Points if it is helpful
    Thanks
    Seshu

  • ERROR WHILE RUNNING THE SESSION IN SM35

    Hi all
            when ever m running this session in SM35 , M getting error as :
    "LEAVE TO TRANSACTION" MARA-BISMT is not allow
    in batch input                               
    REPORT  YASEC_BDC_NIK_SESSION
            no standard page heading
            message-id zmm
            line-count 65
            line-size 150.
    tables : mara.
    *Top includr program
    INCLUDE YNEW_MAIN_TOP.
    *include yasec_bdc_nik_session_top.
    ***********selection screen *******************
    selection-screen begin of block b1 with frame title text-001.
    selection-screen skip.
    PARAMETERS: p_ifile(128)   TYPE c .
    SELECTION-SCREEN SKIP.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
    PARAMETERS: rad1  TYPE c RADIOBUTTON GROUP 1 USER-COMMAND gr1,
                rad2  TYPE c RADIOBUTTON GROUP 1 .
    SELECTION-SCREEN SKIP.
    PARAMETERS: p_sess TYPE c.
    SELECTION-SCREEN END OF BLOCK b2.
    SELECTION-SCREEN SKIP.
    SELECTION-SCREEN END OF BLOCK b1.
    Subroutine call***************************
    INCLUDE YNEW_MAIN_F01.
    *include yasec_bdc_nik_session_f01.
    *********At selection event triggered *************
    at selection-screen on value-request for p_ifile.
    To get F4 help for the input file path
      PERFORM f_f4_input_file.
    AT SELECTION-SCREEN ON p_ifile.
    To validate and upload the input file
      PERFORM f_load_file.
    AT SELECTION-SCREEN ON p_sess.
    To validate the Number of Sessions field
      IF rad2 IS NOT INITIAL AND sy-ucomm EQ c_onli.
        PERFORM f_check_sessions.
      ENDIF.
    ***********Start of selection *******************
    start-of-selection.
    *To process BDC
      PERFORM f_process_bdc.
           TOP OF PAGE
    TOP-OF-PAGE.
    Writes the report heading and for displaying line number.
      PERFORM f_report_header.
    TYPES : BEGIN OF t_final,
            matnr(50) TYPE c,
            bismt(18) type c,
            end of t_final.
    TYPES: BEGIN OF t_fdata,
            data(256) TYPE c,
           END OF t_fdata.
    TYPES: BEGIN OF t_error,
            message(100) TYPE c,
            END OF t_error.
    *Internal table declarations
    *Internal table to load the data from the file that is changed throgh BDC
    DATA : i_final TYPE STANDARD TABLE OF t_final,
           wa_final TYPE t_final.
    *Internal table to store the error messages
    DATA : i_error TYPE STANDARD TABLE OF t_error,
           wa_error TYPE t_error.
    *Internal table to load the raw data
    DATA : i_fdata TYPE STANDARD TABLE OF t_fdata,
           wa_fdata TYPE t_fdata.
    *Internal table to store records of BDC
    DATA : i_bdcdata TYPE STANDARD TABLE OF bdcdata INITIAL SIZE 0,
           wa_bdcdata TYPE bdcdata.
    Internal table to store BDC messages
    DATA: i_bdcmsgcoll TYPE STANDARD TABLE OF bdcmsgcoll INITIAL SIZE 0,
          wa_bdcmsgcoll TYPE bdcmsgcoll.
    VARIABLE DECLARATIONS
    DATA:  v_ifile      TYPE string,
           v_input      TYPE i,
           c_delimiter  TYPE c VALUE 'X',
           v_mode       TYPE c VALUE 'A',
           v_sessions   TYPE i.
    CONSTANTS
    CONSTANTS : c_flagx    TYPE   c VALUE 'X',
                c_slash    TYPE   c VALUE '/',
                c_onli(4)  TYPE   c VALUE 'ONLI',
                c_vl02(4)  TYPE   c VALUE 'VL02',
                c_s        TYPE   c VALUE 'A'.
    FORM f_f4_input_file .
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          program_name  = syst-cprog
          dynpro_number = syst-dynnr
        IMPORTING
          file_name     = p_ifile.
    ENDFORM.                    " f_f4_input_file
    *&      Form  f_load_file
    FORM f_load_file .
      v_ifile = p_ifile.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                =  v_ifile
          filetype                =  'ASC'
         has_field_separator    =  'X'
        TABLES
          data_tab                = i_fdata
        EXCEPTIONS
          file_open_error         = 1
          file_read_error         = 2
          no_batch                = 3
          gui_refuse_filetransfer = 4
          invalid_type            = 5
          no_authority            = 6
          unknown_error           = 7
          bad_data_format         = 8
          header_not_allowed      = 9
          separator_not_allowed   = 10
          header_too_long         = 11
          unknown_dp_error        = 12
          access_denied           = 13
          dp_out_of_memory        = 14
          disk_full               = 15
          dp_timeout              = 16
          OTHERS                  = 17.
      IF sy-subrc <> 0.
    *Text-103-Input file does not exist.
        MESSAGE e000 WITH text-103 .
      ELSEIF NOT i_fdata IS INITIAL.
        DELETE i_fdata WHERE data = space.
        DESCRIBE TABLE i_fdata LINES v_input.
      ENDIF.
      IF v_input EQ 0.
    Text-104 - Input file is empty.
        MESSAGE e000 WITH text-104 .
      ENDIF.
    ENDFORM.                    " f_load_file
    *&      Form  f_check_sessions
    FORM f_check_sessions .
      IF p_sess IS INITIAL.
        MESSAGE e000 WITH text-106.
      ELSE.
        v_sessions = v_input DIV p_sess.
      ENDIF.
    ENDFORM.                    " f_check_sessions
    *&      Form  f_process_bdc
          text
    FORM   f_process_bdc.
      LOOP AT i_fdata INTO wa_fdata.
        SPLIT wa_fdata AT cl_abap_char_utilities=>horizontal_tab
        INTO  wa_final-matnr
              wa_final-bismt.
        APPEND wa_final TO i_final.
        CLEAR wa_fdata.
      ENDLOOP.
      IF rad1 = c_flagx.
        PERFORM f_passbdc_vl02.
      ELSEIF rad2 = c_flagx.
        PERFORM f_sessions_vl02.
      ENDIF.
    ENDFORM.                    "f_process_bdc
    To populate the Screen information
       p_program   Program Name
       p_dynpro    Screen Number
    FORM bdc_dynpro USING  p_program TYPE any
                             p_dynpro TYPE any.
      CLEAR wa_bdcdata.
    Populate the BDC structure with the Screen Information.
    Move the Program name PROGRAM
      wa_bdcdata-program  = p_program.
    Move the Screen Number DYNPRO
      wa_bdcdata-dynpro   = p_dynpro.
    Indicate the beginning of a new screen
      wa_bdcdata-dynbegin = c_flagx.
      APPEND wa_bdcdata TO i_bdcdata.
    ENDFORM.                    "f_bdc_dynpro
    *&      Form  f_passbdc_vl02
          text
    FORM f_passbdc_vl02.
      DATA: l_lines_im TYPE i.
      SORT i_final BY matnr ASCENDING.
      CLEAR wa_final.
      LOOP AT i_final INTO wa_final.
        CLEAR: i_bdcmsgcoll[],
               wa_bdcmsgcoll,
               wa_bdcdata.
          CLEAR: i_bdcdata[].
    perform bdc_dynpro      using 'SAPLMGMM' '0060'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RMMG1-MATNR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'RMMG1-MATNR'
                                  wa_final-matnr.
    perform bdc_dynpro      using 'SAPLMGMM' '0070'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MSICHTAUSW-DYTXT(01)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    perform bdc_field       using 'MSICHTAUSW-KZSEL(01)'
                                  'X'.
    perform bdc_dynpro      using 'SAPLMGMM' '4004'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MARA-BISMT'.
    perform bdc_field       using 'MARA-BISMT'
                                  wa_final-bismt.
    perform bdc_dynpro      using 'SAPLSPO1' '0300'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=YES'.
    perform bdc_transaction using 'MM02'.
    perform bdc_dynpro      using 'SAPLMGMM' '0060'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RMMG1-MATNR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_dynpro      using 'SAPLMGMM' '0070'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MSICHTAUSW-DYTXT(01)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    perform bdc_dynpro      using 'SAPLMGMM' '4004'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RMMG1-MATNR'.
    perform bdc_dynpro      using 'SAPLSPO1' '0300'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=YES'.
    perform bdc_transaction using 'MM03'.
          CALL TRANSACTION 'MM02' USING i_bdcdata
                                 MODE   v_mode
                                 UPDATE c_s
                                 MESSAGES INTO i_bdcmsgcoll.
    If error occurred in call transaction 'VA02' then stores all
    information of failed records into internal table i_error_im.
          IF sy-subrc NE 0.
            DESCRIBE TABLE i_bdcmsgcoll LINES l_lines_im.
            CLEAR wa_bdcmsgcoll.
            READ TABLE i_bdcmsgcoll INTO wa_bdcmsgcoll INDEX l_lines_im.
    To capture success and error messages in BDC.
            CALL FUNCTION 'FORMAT_MESSAGE'                      "#EC *
              EXPORTING
                id        = wa_bdcmsgcoll-msgid
                lang      = wa_bdcmsgcoll-msgspra
                no        = wa_bdcmsgcoll-msgnr
                v1        = wa_bdcmsgcoll-msgv1
                v2        = wa_bdcmsgcoll-msgv2
                v3        = wa_bdcmsgcoll-msgv3
                v4        = wa_bdcmsgcoll-msgv4
              IMPORTING
                msg       = wa_error-message
              EXCEPTIONS
                not_found = 1
                OTHERS    = 2.
            IF sy-subrc <> 0.
            ENDIF.
          ELSE.
            WRITE:  text-111 COLOR 7.
          ENDIF.
        CLEAR: wa_final.
        REFRESH i_bdcdata.
      ENDLOOP.
    ENDFORM.                     "f_passbdc_va02
    *&      Form  bdc_field
          text
         -->P_FNAM     text
         -->P_FVAL     text
    FORM bdc_field USING p_fnam TYPE any
                           p_fval TYPE any.
      CLEAR wa_bdcdata.
    Populate the Field Name
      wa_bdcdata-fnam = p_fnam.
    Populate the field value
      wa_bdcdata-fval = p_fval.
      APPEND wa_bdcdata TO i_bdcdata.
    ENDFORM.                    "f_bdc_field
    *&      Form  f_sessions_vl02
          text
    FORM f_sessions_vl02 .
      DATA: l_sindex TYPE sy-tabix VALUE 1,
            l_eindex TYPE sy-tabix,
            l_flag TYPE c VALUE space.
      l_eindex = v_input.
      SORT i_final BY matnr ASCENDING.
      DO p_sess TIMES.
        CALL FUNCTION 'BDC_OPEN_GROUP'
          EXPORTING
            client              = sy-mandt
            group               = 'Y_VL02_NIK'
            user                = sy-uname
           keep                = c_flagx
          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.
        CLEAR wa_final.
        CLEAR: i_bdcdata[].
        LOOP AT i_final INTO wa_final FROM l_sindex TO l_eindex .
            IF l_flag = v_sessions.
              CLEAR l_flag.
              EXIT.
            ENDIF.
            l_flag = l_flag + 1.
            CLEAR: i_bdcdata[].
    perform bdc_dynpro      using 'SAPLMGMM' '0060'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RMMG1-MATNR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'RMMG1-MATNR'
                                  wa_final-matnr.
    perform bdc_dynpro      using 'SAPLMGMM' '0070'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MSICHTAUSW-DYTXT(01)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    perform bdc_field       using 'MSICHTAUSW-KZSEL(01)'
                                  'X'.
    perform bdc_dynpro      using 'SAPLMGMM' '4004'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MARA-BISMT'.
    perform bdc_field       using 'MARA-BISMT'
                                  wa_final-bismt.
    perform bdc_dynpro      using 'SAPLSPO1' '0300'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=YES'.
    perform bdc_transaction using 'MM02'.
    perform bdc_dynpro      using 'SAPLMGMM' '0060'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RMMG1-MATNR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_dynpro      using 'SAPLMGMM' '0070'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MSICHTAUSW-DYTXT(01)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    perform bdc_dynpro      using 'SAPLMGMM' '4004'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RMMG1-MATNR'.
    perform bdc_dynpro      using 'SAPLSPO1' '0300'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=YES'.
    perform bdc_transaction using 'MM03'.
          l_sindex = l_sindex + 1.
        ENDLOOP.
        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.
      ENDDO.
    ENDFORM.                    " f_sessions_vl02
    *&      Form  f_report_header
    FORM f_report_header .
      FORMAT COLOR COL_HEADING INTENSIFIED ON.
      ULINE.
    text-201 - Company: Carrier
    text-102-  Batch Data Communication.
    text-202 - System: SAP
      WRITE: /1   sy-vline,
              3   text-201,
              50  text-102,
              100 text-202,
              AT  sy-linsz sy-vline.
    text-203 - Program:
    text-204 - Date/Time:
      WRITE: /1   sy-vline,
              3   text-203, sy-repid ,
              100 text-204,sy-datum ,c_slash, sy-uzeit,
              AT  sy-linsz sy-vline.
    text-205 - User ID:
    text-206 - Page:
      WRITE: /1   sy-vline,
              3   text-205, sy-uname,
              100 text-206, sy-pagno,
              AT  sy-linsz sy-vline.
      FORMAT COLOR OFF.
      ULINE.
    ENDFORM.                    " f_report_header
    FORM bdc_transaction USING tcode.
      CALL FUNCTION 'BDC_INSERT'
        EXPORTING
          tcode            = tcode
        TABLES
          dynprotab        = i_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.
      ELSE.
        WRITE: / text-109 ,wa_final-matnr,
                 text-110 .
      ENDIF.
    ENDFORM.                    "bdc_transaction

    please check this
    check all perform bdcfield correct or not....
    perform bdc_dynpro using 'SAPLMGMM' '0060'.
    perform bdc_field using 'BDC_CURSOR'
    'RMMG1-MATNR'.
    perform bdc_field using 'BDC_OKCODE'
    '/00'.
    perform bdc_field using 'RMMG1-MATNR'
    wa_final-matnr.
    perform bdc_dynpro using 'SAPLMGMM' '0070'.
    perform bdc_field using 'BDC_CURSOR'
    'MSICHTAUSW-DYTXT(01)'.
    perform bdc_field using 'BDC_OKCODE'
    '=ENTR'.
    perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
    'X'.
    perform bdc_dynpro using 'SAPLMGMM' '4004'.
    perform bdc_field using 'BDC_OKCODE'
    '/00'.
    perform bdc_field using 'BDC_CURSOR'
    'MARA-BISMT'.
    perform bdc_field using 'MARA-BISMT'
    wa_final-bismt.
    perform bdc_dynpro using 'SAPLSPO1' '0300'.
    perform bdc_field using 'BDC_OKCODE'
    '=YES'.
    perform bdc_transaction using 'MM02'.
    perform bdc_dynpro using 'SAPLMGMM' '0060'.
    perform bdc_field using 'BDC_CURSOR'
    'RMMG1-MATNR'.
    perform bdc_field using 'BDC_OKCODE'
    '/00'.
    perform bdc_dynpro using 'SAPLMGMM' '0070'.
    perform bdc_field using 'BDC_CURSOR'
    'MSICHTAUSW-DYTXT(01)'.
    perform bdc_field using 'BDC_OKCODE'
    '=ENTR'.
    perform bdc_dynpro using 'SAPLMGMM' '4004'.
    perform bdc_field using 'BDC_OKCODE'
    '/00'.
    perform bdc_field using 'BDC_CURSOR'
    'RMMG1-MATNR'.
    perform bdc_dynpro using 'SAPLSPO1' '0300'.
    perform bdc_field using 'BDC_OKCODE'
    '=YES'.
    perform bdc_transaction using 'MM03'.

  • BDC programming using Batch input Session.

    Hello Experts.
    I'm an ABAP beginner. I've benn practicing BDC programming using Batch input Session
    at the moment.
    This is the program that upload Local file which has plural records, and put the records into a Session.
    These are the records.
    413459,KIM EI HWAN121                ,19810607,MIADONG1234
    423459,KIM EI HWAN122                ,19810607,MIADONG1235
    433459,KIM EI HWAN123                ,19810607,MIADONG1236
    443459,KIM EI HWAN124                ,19810607,MIADONG1237
    453459,KIM EI HWAN125                ,19810607,MIADONG1238
    463459,KIM EI HWAN126                ,19810607,MIADONG1239
    I succeeded making Session.
    However, for some reaseon, every record in the Session has got the same, value which is the first record.
    Why is this happening? And How can I correct the code below?
    REPORT ZBCUSER002_BATCH NO STANDARD PAGE HEADING
                            LINE-SIZE 255
                            MESSAGE-ID ZBATCH.
    = Types definition ===================================================
    TYPES: BEGIN OF TYP_LOCAL,               "For Local file upload
             RECORD(200) TYPE C,
           END   OF TYP_LOCAL.
    = Internal table definition ==============================================
    DATA: BEGIN OF BDC_TAB OCCURS 0.        "BDCDATA itab
            INCLUDE STRUCTURE BDCDATA.
    DATA: END   OF BDC_TAB.
    DATA: BEGIN OF MESSAGE_BDC OCCURS 0.    "Message itab
            INCLUDE STRUCTURE BDCMSGCOLL.
    DATA: END   OF MESSAGE_BDC.
    DATA: TBL_LOCAL TYPE STANDARD TABLE OF TYP_LOCAL,  "Local file itab
          F_TBL     TYPE FILETABLE.                    "FILETABLE fot local
    = Structure table definition =========================================
    DATA: STR_F_TBL LIKE LINE OF F_TBL,                "FILETABLE structure
          STR_LOCAL TYPE TYP_LOCAL.                    "Local file structure
    = Variable definition ================================================
    DATA: LV_RC     TYPE I,                            "Method parameter
          ENUMBER   TYPE ZT601-ENUMBER,                "Employee number
          NAME      TYPE ZT601-NAME,                   "Employee name
          BIRTH     TYPE ZT601-BIRTH,                           "Birthday
          HOMETOWN  TYPE ZT601-HOMETOWN,                        "Hometown
          SYSVAL    TYPE SY-SUBRC.                     "System valuible
    = Constants definition ===============================================
    CONSTANTS: TBL_NAME(10) TYPE C VALUE 'ZT601'.      "Table name ZT601
    = Parameters definition ==============================================
    PARAMETERS: F_NAME      TYPE RLGRAP-FILENAME OBLIGATORY,    "File path
                EXECMODE(1) TYPE C.                    "Execute mode
    INITIALIZATION
    *----- Initialize all valuables, structures and internal tables
    CLEAR: LV_RC,
           STR_F_TBL,
           STR_LOCAL,
           ENUMBER,
           NAME,
           BIRTH,
           HOMETOWN.
    REFRESH: F_TBL,
             TBL_LOCAL.
    AT SELECTION-SCREEN
    *----- When the button next to Parameter 'F_NAME',
    *----- File dialog open.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR F_NAME.
      CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
        EXPORTING
          WINDOW_TITLE            = 'SELECT FILE'
          DEFAULT_FILENAME        = '*.TXT'
       CHANGING
         FILE_TABLE               = F_TBL
         RC                       = LV_RC
        EXCEPTIONS
          FILE_OPEN_DIALOG_FAILED = 1
          CNTL_ERROR              = 2
          OTHERS                  = 3
    *----- system valiable check.
    *----- If done properly,
    *----- Put the path into the File path parameter
      IF SY-SUBRC = 0.
        READ TABLE F_TBL INTO STR_F_TBL INDEX 1.
        F_NAME = STR_F_TBL.
    *----- If not done properly, show message
    *----- An error occured while getting file path then end program
      ELSE.
        MESSAGE E000.
      ENDIF.
    *----- Execute code can only be A or N.
    AT SELECTION-SCREEN ON EXECMODE.
      IF EXECMODE <> 'A' AND EXECMODE <> 'N'.
        MESSAGE E001.
      ENDIF.
    START-OF-SELECTION
    START-OF-SELECTION.
    *----- Upload Local file of file path parameter.
      CALL FUNCTION 'GUI_UPLOAD'
           EXPORTING
                FILENAME                = F_NAME
                FILETYPE                = 'ASC'
           TABLES
                DATA_TAB                = TBL_LOCAL
           EXCEPTIONS
                FILE_OPEN_ERROR         = 1
                FILE_READ_ERROR         = 2
                NO_BATCH                = 3
                GUI_REFUSE_FILETRANSFER = 4
                INVALID_TYPE            = 5
                OTHERS                  = 6.
    *----- System valiable check.
    *----- If not done properly, show an error message
    *----- An error occured while uploading local file then end program
      IF SY-SUBRC <> 0.
        MESSAGE E002.
      ENDIF.
      PERFORM BDC_OPEN.
    *----- Loop Internal table
      LOOP AT TBL_LOCAL INTO STR_LOCAL.
    *----- Spilt the file record and put them into each valiable.
        SPLIT STR_LOCAL AT ',' INTO  ENUMBER
                                     NAME
                                     BIRTH
                                     HOMETOWN.
    *----- Data check Function module
        CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
             EXPORTING
                  DATE                      = BIRTH
             EXCEPTIONS
                  PLAUSIBILITY_CHECK_FAILED = 1
                  OTHERS                    = 2.
    *----- When error occurs while checking date, show an error message.
    *----- (&1) is not date
        IF SY-SUBRC <> 0.
          MESSAGE E003 WITH BIRTH.
        ENDIF.
    *-- The first screen of SE11
    *----- Screen number 0102 of program id SAPMSRD0
        PERFORM BDC_DYNPRO      USING 'SAPMSRD0' '0102'.
        PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                      'RSRD1-TBMA_VAL'. "Field on Cursor
        PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                      '=SHOW'.          "Display button
        PERFORM BDC_FIELD       USING 'RSRD1-TBMA'
                                      'X'.
        PERFORM BDC_FIELD       USING 'RSRD1-TBMA_VAL'
                                       TBL_NAME.                "ZT601
    *-- Table definition screen
    *----- Screen number 2000 of program id SAPLSD02
        PERFORM BDC_DYNPRO      USING 'SAPLSD02' '2000'.
        PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                      'DD02D-TABCLTEXT'.  "Field on Cursor
        PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                      '=TDED'.            "Create entry
        PERFORM BDC_FIELD       USING 'BDC_SUBSCR'
                                      'SAPLSD02'.
        PERFORM BDC_FIELD       USING 'BDC_SUBSCR'
                                      'SAPLSED5'.
    *-- Data input screen
    *----- Screen number 0101 of program /1BCDWB/DBZT601
        PERFORM BDC_DYNPRO      USING '/1BCDWB/DBZT601' '0101'.
        PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                      'ZT601-CRUSER'.    "Field on Cursor
        PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                      '=SAVE'.                  "Save
        PERFORM BDC_FIELD       USING 'ZT601-MANDT'
                                      SY-MANDT.                 "Client
        PERFORM BDC_FIELD       USING 'ZT601-ENUMBER'
                                      ENUMBER.           "Employee number
        PERFORM BDC_FIELD       USING 'ZT601-NAME'
                                      NAME.              "Employee name
        PERFORM BDC_FIELD       USING 'ZT601-BIRTH'
                                      BIRTH.                    "Birthday
        PERFORM BDC_FIELD       USING 'ZT601-HOMETOWN'
                                      HOMETOWN.                 "Hometown
        PERFORM BDC_FIELD       USING 'ZT601-CRDATE'
                                      SY-DATUM.          "System date
        PERFORM BDC_FIELD       USING 'ZT601-CRTIME'
                                      SY-UZEIT.          "System time
        PERFORM BDC_FIELD       USING 'ZT601-CRUSER'
                                      SY-UNAME.          "System user
    *-- Data input screen (After input)
    *----- Screen number 0101 of program /1BCDWB/DBZT601
        PERFORM BDC_DYNPRO      USING '/1BCDWB/DBZT601' '0101'.
        PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                      '/EBACK'.                 "Back
        PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                      'ZT601-CRUSER'.    "Field on Cursor
    *-- Table definition screen]
    *----- Screen number 2000 of program SAPLSD02
        PERFORM BDC_DYNPRO      USING 'SAPLSD02' '2000'.
        PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                      'DD02D-TABCLTEXT'.  "Field on Cursor
        PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                      '=WB_BACK'.               "Back
    *-- The first screen of SE11
    *----- Screen number 0102 of program SAPMSRD0
        PERFORM BDC_DYNPRO      USING 'SAPMSRD0' '0102'.
        PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                      'RSRD1-TBMA_VAL'.   "Field on Cursor
        PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                      '=BACK'.
        PERFORM BDC_FIELD       USING 'RSRD1-TBMA'
                                      'X'.
        PERFORM BDC_FIELD       USING 'RSRD1-TBMA_VAL'
                                      TBL_NAME.
        PERFORM BDC_INSERT.
      ENDLOOP.
      PERFORM BDC_CLOSE.
          FORM BDC_DYNPRO                                               *
          Put Program-Id, Dynpro screen number, Start point
          into DBCDATA
    -->  PROGRAM                                                       *
    -->  DYNPRO                                                        *
    FORM BDC_DYNPRO USING PROGRAM DYNPRO.
      CLEAR BDC_TAB.
      BDC_TAB-PROGRAM  = PROGRAM.
      BDC_TAB-DYNPRO   = DYNPRO.
      BDC_TAB-DYNBEGIN = 'X'.
      APPEND BDC_TAB.
    ENDFORM.
          FORM BDC_FIELD                                                *
          Put Field Name and Value into BDCDATA
    -->  FNAM                                                          *
    -->  FVAL                                                          *
    FORM BDC_FIELD USING FNAM FVAL.
      CLEAR BDC_TAB.
      BDC_TAB-FNAM = FNAM.
      BDC_TAB-FVAL = FVAL.
      APPEND BDC_TAB.
    ENDFORM.
          FORM bdc_process                                              *
    FORM BDC_OPEN.
      CALL FUNCTION 'BDC_OPEN_GROUP'
           EXPORTING
                CLIENT = SY-MANDT
                GROUP  = 'Testsession'
                KEEP   = 'X'
                USER   = SY-UNAME.
      IF SY-SUBRC <> 0.
        MESSAGE E006 WITH SY-SUBRC.
      ENDIF.
    ENDFORM.
          FORM bdc_insert                                               *
    FORM BDC_INSERT.
      CALL FUNCTION 'BDC_INSERT'
           EXPORTING
                TCODE            = 'SE11'
           TABLES
                DYNPROTAB        = BDC_TAB
           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 E007 WITH SY-SUBRC.
      ENDIF.
      CLEAR: BDC_TAB.
    ENDFORM.
          FORM bdc_close                                                *
    FORM BDC_CLOSE.
      CALL FUNCTION 'BDC_CLOSE_GROUP'
           EXCEPTIONS
                NOT_OPEN    = 1
                QUEUE_ERROR = 2
                OTHERS      = 3.
      IF SY-SUBRC <> 0.
        MESSAGE E008 WITH SY-SUBRC.
      ENDIF.
    ENDFORM.

    God I forgot to refresh Internal table after putting record into Session.
    Now I'm done.
    You guys be careful too.

Maybe you are looking for