Run the program in Background

Hello All,
I have selection screen where i have parameters for programs, classes and filename.
When i give program name and filename and execute. A Popup appears and asks the path for the file to be saved in xml format. This is done through foreground. It is working correctly in foreground and the file saves in xml format in specified location.
I have tried using the JOB Schedule for background but it is not working.
My requirement is to do the same process in background. How can i achieve the same process as foreground for the given programs and classes to save the file in xml format through background process.
Could anybody help me in this issue.
Thanks

Hello Indrakaran Reddy,
You cannot run the programs which involves the user intervention,pop-up displays etc., in the background mode.
For this, you need to have the file in the application server not on the desktop(presentation server).
Once, your file is in the application server, give the class and path of the file in the selection screen and then save it as a variant.
Then, schedule the program in the background using the transaction SM36.
This is how it works. Hope you understood the concept clearly.
Thanks,
Babu Kilari

Similar Messages

  • Problem while running the program in background

    hi SDNs,
    i have problem while i run report in background. in background, last three columns  are not appearing in the report. whereas it showing all columns in foreground.
    i have increased the line-size, even then it is giving truncating last some columns.
    could you any one pls help me out, what to do ?
    Thanking you,
    Ramakrishna S

    hi prakash ramu,
    even it is not working. it is directly talking me to spool request..
    i think it is not possible, while ur running the report in background.,
    any how if possible could u pls send me the code...
    thanks
    ramu

  • How tu run the program in background

    Hi SapAll.
    actually iam new to ABAP ,i just want to know on how i can run the particular program  in background .
    can any one explain me in steps .
    i also want to know on how to delete the particular job which has been already created in sm36 .
    will be waiting for best response.
    regards.
    Varma

    Hi
    Find the below steps to be defined.
    1. Go to SM36 -
    > Give the Program Name
    2. If you have priority defined that to in Job class
    3. Click -
    > Start Condition
    4. Select Data/Time Tab
    5. Give the Date and Time for the job execution. (If you want to certain intervale provide it)

  • Running the program in background

    Hi Friends,
    Can you tell me how to enable a program to run in background, please.
    Thanks for the help.
    venu

    Hi Venu,
    Let me make one thing clear. A background job doesnt mean its someother program running. It just means the program doesnt run online but it runs as a task.
    Point two you need not have to write any code for it, all that you need to do is schedule a job.
    Point three, if you are getting baffled with what's JOB_OPEN,.... and other function modules, then let me make a point clear. You manually schedule a job in SM36/SM37 but if you schedule it in a program then you use these FMs.
    You generally use it when data is large and you dont want the user to wait till the execution is complete.
    Please remember to what Christian was referring to.
    Rgrds,
    Srikanth

  • How to run the program in background job,program should run in 3 days.

    Dear Gurus,
    i have a program , that program should run approximately 3 days to get the result.
    i scheduled this program as a background job.
    how can i run sto5 t-code for this same program.
    i that case how we can trace the output.
    Experts please help me out.
    Thank u very much.
    Regards
    sudheer

    Hello Sudheer,
    The trace can be set on background jobs by using ST12 transaction. Please make sure that the trace is activated for only few minutes in production environment.
    Contact your basis team to activate trace on background job and the transaction used is ST12.
    Thanks

  • To run a program in BACKGROUND using SUBMIT

    I need to run a program in background using the SUBMIT option. Here i have to pass an internal table form one program to another which will be used to update sales orders using BDC.
    Questions
    1} Can we execute a program in background using SUBMIT?
    2} I am sending data to a MEMORY ID , if i run the program in background will the memory id work. As in do  memory IDs work in the background.
    Thanks in Advance

    refer  same thread.
    Re: Problem with SUBMIT in Background

  • I have a problem in processing the program in background

    Hi,
    We have cloned the T'code V_V2 and added some additional functionality and when we try to run the program in background the error is blocking the process
    This is because, say example i am tring to process the sales order in production systen through my program ,in that time some one may chage the sales document . in trhis case my program should not blocked it should check the block before processing and then it should proceed.
    is there any FM to find the blocked sales order.
    Regards,
    Vijay

    Try using the FM:
    ENQUE_READ2
    Passing the follwing values:
    GNAME --> VBAK (Sales Order header table)
    GARG   --> The lock argument
                       (This will be a combination of client number anb Sales Order No.
                        Eg: '3001210000054' where the first three digit i,e 300 is the client No
                       and 1210000054 is the sales order no.)
    Regards,
    Firoz.

  • Running BDC program in background for the transaction VL02N

    Hi All,
    I have coded a BDC program (call transaction method) for the transaction code VL02N. I can able to run the program manually & successfully. But if I execute the program in background(SM36), it is going to dump giving CNTL_ERROR.
    Note: I am not using any of the GUI_UPLOAD, GUI_DOWNLOAD funciton modules in the program. But I am using the FTP command funtion modules like( FTP_COMMAND, FTP_CONNECT, FTP_DISCONNECT and FTP_SERVER_TO_R/3).
    <removed_by_moderator>
    Thanks in advance.
    Ramesh.
    Edited by: Julius Bussche on Jul 8, 2008 5:55 PM

    VL02N is an enjoy transaction. You cant run it in background. Please try VL02.
    Thanks
    Romit

  • How to run a program in background and how to check the output

    I have to run my program as background job... it has a selection screen...... and i need to check the output after its complete.

    hi,
    u need to create one program for this.
    tables:btcevtjob.
    parameters:job(32).
    data:count like btcevtjob-jobcount.
    call the function modules JOB_OPEN,JOB_SUBMIT AND JOB_CLOSE
    and pass the parameters in those function modules.
    once u execute this program,
    go with sm37->provide jobname->select the option scheduled
    ->execute
    selct the entry->go with release option.
    under releasae select immediate option
    save
    select the job name again
    go with release
    status is in finished stage
    now go with spool option
    give spool no
    go for display
    o/p displayed.
    before this,go for se38->provide the name of program which u want to run in back ground->seelct variants->change->provide variant name->go for create->provide input value->go with attributes->provide description->save
    this variant name u have to give in the job_submit fm.
    or
    se38->program->execute->in back ground
    Reward points if useful,
    Thanks,
    Usha

  • Running the program which saves file in sap directory in background

    Hi guys,
    how to Run the program which saves file in sap directory in background? Thanks!

    Hi Mark,
    AL11 is a transaction that shows your application server something like an windows browser.
    If you want to store file in your application server then you can write a code which uploads the data in to a file on application server.And you can run your code in background also.
    Use function module :SAP_DATA_CONVERT_WRITE_FILE to write file on the application server.
    If you want to upload file manually then use TCODE :CG3Z.
    Hope this will you out.

  • Setting Variants and running the program in the background.

    Hi experts,
    I have a custom program which needs to be executed in the background with a set of variants on every monday. For this I will execute the program in background and i will set the time and date.
    One of my variants in the screen is the running date based on which the records will be fetched from the table in the program.
    When i run on 29/05/2006 (MONDAY) the date select option should be set as 23/05/2006 to 29/05/2006.
      how should i do this.
    regards,
    Arul Jothi.

    Hi,
    You can change the DATE values dynamically. Look at the variant options.
    While saving the variant, click on the SELECTION OPTIONS for the DATE parameter (Select the L Parameter check box) and you can specify the dates.
    Here you specify the DYNAMIC DATE CALCULATION WHERE YOU can specify the high and low values.
    Regards,
    Ravi
    Note : Please mark all the helpful answers

  • /SAPAPO/SDRQCR21 program is not working correctly if we run the program for range of material and plant wise

    Hi APO Experts,
    In our project, we have received more sales order inconsistencies which is not clearing by CCR program and it is clearing by  program /SAPAPO/SDRQCR21 with option as Build Reqmts from Doc. Flow, So We have decided to schedule the background job on daily basis for program /SAPAPO/SDRQCR21 with option as Build Reqmts from Doc. Flow, performing the testing in our quality system and observed the below strange behavior. 
    When I am running the program /SAPAPO/SDRQCR21 with Range of products and some location range with option as Build Reqmts from Doc. Flow, in Background job. In output it is suggesting to delete one sales order. If I checked that Sales order in ECC, it is for an different location, that is not part of my selection and the order is open. In MD04 the Qty is showing 1 ( as per sales order) but in APO RRP3 view the order qty is showing Zero. I have run the CCR, it is coming in different in content and if I push, the different is not going to APO.
    I have tried running the program /SAPAPO/SDRQCR21 with plant which is mentioned in that sales order with option as Build Reqmts from Doc. Flow, in Background job , it is suggesting this sales order under update option correctly.   
    Can you please help me understand why it is behaving differently like the location is not part of my selection and why it is suggesting the wrong action. And also whether is it advisable to run the /SAPAPO/SDRQCR21 with option as Build Reqmts from Doc. Flow at plant range and material range in background job.
    Thanks & Regards,
    Sundaram Radhakrishnan

    Sundaram,
    It sounds to me like the sales document records in the OLTP and in APO were created at different times.  This is common in Dev and Qual environments when the systems are commonly created at two different times, and each was a copy of an existing system that contained sales data.  The order number you see in //rrp3 is somewhat irrelevant; system generally uses the guid for many activities.
    FYI during Dev and Qual refreshes, if you are copying from a production environment that contains data, it is always best to create the OLTP and SCM images at the same time, and to copy them both to the Dev and Qual systems at the same time.  If you don't do this, you are faced with the additional tasks associated with getting the copied systems back into synch.
    If this is Dev or Qual, I suggest that you just completely wipe out all sales orders in APO and rebuild them using the CIF.
    If this is a mature production environment, the only time I have ever seen this issue is due to improperly created CIF enhancements.  Speak to your developers to find the root cause, and correct this problem.  Then, wipe out all sales orders and rebuild with CIF.
    Best Regards,
    DB49

  • Headers getting repeated while running the report in background

    Hi,
    I have a report which uses ALV grid display for output display.
    I have displayed a heder in the top_of_page option. while running the program in foregound the header gets displayed only once. but when executing in background the header is getting displayed for each and every page.
    can any one tell me how to get the header displayed only once in the background also.

    REPORT  ZBACKORD MESSAGE-ID VZ
                                  NO STANDARD PAGE HEADING.
    *& TABLES AND TYPE-POOLS                                               *
    Tables used
    TABLES : VBAK,    "Sales Document: Header Data
             VBAP,    "Sales Document: Item Data
             VBPA.    "Sales Document Partner
    For ALV Display
    TYPE-POOLS: SLIS.  "Globale Typen für generische Listbausteine
    *& CONSTANTS                                                           *
    Constants Used
    CONSTANTS:
               C_X         VALUE 'X',           "Order status
               C_TAPA(4)   VALUE 'TAPA',        "For Material Determination
               C_0001(4)   VALUE '0001',        "Etenr value
               C_A         VALUE 'A',           "Enable Save
               C_US(3)  VALUE 'US$',            "US DOLLAR.
               C_B         VALUE 'B',           "for Partially processed
               C_E         VALUE 'E',           "Language
               C_C         VALUE 'C',           "for completely processed
               C_BLANK     VALUE ' ',           "Blank
               C_IC1(4) VALUE '&IC1',           "for user command
               C_ZR(2)     VALUE 'ZR',          "Cs ReP No
               C_BP(2)     VALUE 'RE',          "Bill to party
               C_SH(2)     VALUE 'WE',          "Sold to party
              C_6(6)      VALUE '000000',      "For item number
               C_20(2)  TYPE N VALUE '20',      "For the length of the field
               C_S(1)   TYPE C VALUE 'S',       "STOCK
               C_H      VALUE 'H',              "Header
               C_COL(1) TYPE C VALUE ':',       " COLUMN FOR DATA AND TIME
               C_TOP    TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
                                               "For TOP_OF_PAGE
               C_USER   TYPE SLIS_FORMNAME VALUE 'USER_COMMAND'.
    " For USER_COMMAND
    *& TYPE DEFINITIONS                                                    *
    *FOR Sales Document: Header Data
    TYPES: BEGIN OF TP_VBAK,
             VBELN TYPE VBELN_VF,   "Sales Document
             ERDAT TYPE ERDAT,      "Date on which the record was created
             AUART TYPE AUART,      "Sales document type
             LIFSK TYPE LIFSK,      "Delivery block
             VKORG TYPE VKORG,      "Sales organization
             VTWEG TYPE VTWEG,      "Distribution channel
           END OF TP_VBAK.
    *FOR Sales Document Business Data
    TYPES :BEGIN OF TP_VBKD,
            VBELN TYPE VBELN,      "Sales and distribution document number
            POSNR TYPE POSNR,      "Item number of the SD document
            INCO1 TYPE INCO1,      "Incoterms
            ZTERM TYPE DZTERM,     "Terms of payment key
            BSTKD TYPE BSTKD,      "Customer purchase order number
          END OF TP_VBKD.
    TYPES : BEGIN OF TP_VBFA,
              VBELV TYPE VBELN_VON,
              POSNV TYPE POSNR_VON,
            END OF TP_VBFA.
    *FOR Sales Document: Partner
    TYPES : BEGIN OF TP_VBPA,
              VBELN TYPE VBELN,    "Sales and distribution
              PARVW TYPE PARVW,    "Partner function
              KUNNR TYPE KUNNR,    "Customer Number 1
              ADRNR TYPE ADRNR,    "address
            END OF TP_VBPA.
    *FOR Addresses (Business Address Services)
    TYPES : BEGIN OF TP_ADRC,
              ADDRNUMBER TYPE AD_ADDRNUM,  "Address
              DATE_FROM TYPE AD_DATE_FR,   "Date valid from
              NATION TYPE AD_NATION,       "International address
              NAME1 TYPE AD_NAME1,         "name
            END OF TP_ADRC.
    *FOR Sales Document: Item Data
    TYPES: BEGIN OF TP_VBAP,
            VBELN TYPE VBELN_VA,   "Sales document
            POSNR TYPE POSNR_VA,   "Sales document item
            MATNR TYPE MATNR,      "Material Number
            PSTYV TYPE PSTYV,      "Sales document item category
            KDMAT TYPE MATNR_KU,   "Material number used by customer
            VRKME TYPE VRKME,      "Sales unit
            WERKS TYPE WERKS_EXT,  "Plant (Own or External)
            VSTEL TYPE VSTEL,      "Shipping point /Receiving point
            NETPR TYPE NETPR,      "Net p
            NETWR TYPE NETWR_AP,
            WAERK TYPE VBAP-WAERK,"Target outline doc currency
         END OF TP_VBAP.
    *for Sales Document: Schedule Line Data
    TYPES: BEGIN OF TP_VBEP,
            VBELN TYPE VBELN_VA,   "Sales document
            POSNR TYPE POSNR_VA,   "Sales Document Item
            ETENR TYPE ETENR,      "Schedule line
            EDATU TYPE EDATU,      "Schedule line data
            WMENG TYPE WMENG,      "Order quantity in sales unit
            BMENG TYPE BMENG,      "Confirmed quantity
            LMENG TYPE LMENG,      "Required quantity
            WADAT TYPE WADAT,      "Goods issue date
            LIFSP TYPE LIFSP_EP,   "Schedule line blocked for delivery
          END OF TP_VBEP.
    *For Sales Document: Header Status and Administrative Data
    TYPES : BEGIN OF TP_VBUK,
              VBELN TYPE VBELN,  "Sales and Distribution Document Number
              SPSTG TYPE SPSTG,  "Overall blocked status
              CMGST TYPE CMGST,
            END OF TP_VBUK.
    TYPES : BEGIN OF TP_TVLST,
              LIFSP TYPE LIFSP,  "Default delivery block
              VTEXT TYPE BEZEI_LIFSP, "Description
            END OF TP_TVLST.
    *FOR Sales Document: Item Status
    TYPES : BEGIN OF TP_VBUP,
              VBELN TYPE VBELN,      "Sales and distribution
              POSNR TYPE POSNR,      "Item number of the SD
              LFGSA TYPE LFGSA,      "Overall delivery status of item
            END OF TP_VBUP.
    For ALV Display-if  cs rep is checked
    TYPES: BEGIN OF TP_DISPC,
              VBELN TYPE VBELN,       "Sales and distribution Doc
              VKORG TYPE VKORG,       "Sales organization
              VTWEG TYPE VTWEG,       "Distribution channel
              AUART TYPE AUART,       "Sales document type
              BSTKD TYPE BSTKD,       "Customer purchase order
              KUNNR_1 TYPE KUNNR,     "Cs Rep Number
              NAME1_1 TYPE NAME1,     "Cs Rep Name
              KUNNR_2 TYPE KUNNR,     "Bill to Number
              NAME1_2 TYPE NAME1,     "Bill to Party
              KUNNR_3 TYPE KUNNR,     "Ship to Number
              NAME1_3 TYPE NAME1,     "Ship to Party
              POSNR TYPE POSNR_VA,    "Item number of the SD
              MATNR TYPE MATNR,       "Material Number
              KDMAT TYPE MATNR_KU,    "Material number used by
              VSTEL TYPE VSTEL,       "Shipping point /Receiving
              NETPR TYPE NETPR,       "Net price
              NETWR TYPE NETWR_AP,
              WAERK TYPE WAERK,       "Currency
              ZTERM TYPE DZTERM,      "Terms of payment key
              WMENG TYPE WMENG,       "Order quantity in sales unit
              LOGIC_1 TYPE WMENG,     "BackOrder Quantity
              VRKME TYPE STRING,      "Sales Unit
              WADAT TYPE EDATU,       "Goods issue date
              WADAT1 TYPE EDATU,
              EDATU TYPE EDATU,       "Schedule line data
              VRKME_1 TYPE STRING,    "Sales Unit
              INCO1 TYPE INCO1,       "Incoterms
              LFGSA TYPE STRING,      "Overall delivery status of item
              LIFSP TYPE STRING,      "Line Item Block
              LIFSK TYPE STRING,      "Header block
              SPSTG TYPE STRING,      "Overall blocked status
             END OF TP_DISPC.
    For ALV Display-if plant is checked
    TYPES: BEGIN OF TP_DISPP,
              VBELN TYPE VBELN,       "Sales and distribution Doc
              VKORG TYPE VKORG,       "Sales organization
              VTWEG TYPE VTWEG,       "Distribution channel
              AUART TYPE AUART,       "Sales document type
              BSTKD TYPE BSTKD,       "Customer purchase order
              KUNNR_2 TYPE KUNNR,     "Cs rep number
              NAME1_2 TYPE NAME1,     "Cs rep Name
              KUNNR_3 TYPE KUNNR,     "Ship to Number
              NAME1_3 TYPE NAME1,     "Ship to Party Name
              POSNR TYPE POSNR_VA,    "Item number of the SD
              MATNR TYPE MATNR,       "Material Number
              KDMAT TYPE MATNR_KU,    "Material number used by customer
              VSTEL TYPE VSTEL,       "Shipping point /Receiving point
              NETPR TYPE NETPR,       "Net price
              NETWR TYPE NETWR_AP,
    *}MOD02
              WAERK TYPE WAERK,       "Currency
              ZTERM TYPE DZTERM,      "Terms of payment key
              WMENG TYPE WMENG,       "Order quantity in sales unit
              LOGIC_1 TYPE WMENG,     "Backorder Quantity
              VRKME TYPE STRING,      "Sales unit
              WADAT TYPE EDATU,       "Goods issue date
              WADAT1 TYPE EDATU,
              EDATU TYPE EDATU,       "Schedule line data
              VRKME_1 TYPE STRING,    "Sales Unit
              INCO1 TYPE INCO1,       "Incoterms
              LFGSA TYPE STRING,      "Overall delivery status of item
              LIFSP TYPE STRING,      "Line Item Block
              LIFSK TYPE STRING,      "Header block
              SPSTG TYPE STRING,      "Overall blocked status
              WERKS TYPE WERKS_EXT,   "Plant (Own or External)
           END OF TP_DISPP.
    For ALV Display-if cs rep and palnt is checked
    TYPES: BEGIN OF TP_DISP,
              VKORG TYPE VKORG,        "Sales organization
              VTWEG TYPE VTWEG,        "Distribution channel
              AUART TYPE AUART,        "Sales document type
              VBELN TYPE VBELN,        "Sales and distribution Doc no
              BSTKD TYPE BSTKD,        "Customer purchase order number
              KUNNR_1 TYPE KUNNR,      "Cs Rep Number
              NAME1_1 TYPE NAME1,      "Cs Rep Name
              KUNNR_2 TYPE KUNNR,      "Bill to Number
              NAME1_2 TYPE NAME1,      "Bill to Name
              KUNNR_3 TYPE KUNNR,      "Ship to Number
              NAME1_3 TYPE NAME1,      "Ship to Name
              POSNR TYPE POSNR_VA,     "Item number of the SD
              MATNR TYPE MATNR,        "Material Number
              KDMAT TYPE MATNR_KU,     "Material number used
              VSTEL TYPE VSTEL,        "Shipping point /Receiving
              NETPR TYPE NETPR,        "Net price
              NETWR TYPE NETWR_AP,
              WAERK TYPE WAERK,        "Currency
              ZTERM TYPE DZTERM,       "Terms of payment key
              WMENG TYPE WMENG,        "Order quantity in sales
              LOGIC_1 TYPE WMENG,      "Backorder Quantity
              VRKME TYPE STRING,       "Sales unit
              WADAT TYPE EDATU,        "Goods issue date
              WADAT1 TYPE EDATU,
              VRKME_1 TYPE STRING,     "Sales Unit
              EDATU TYPE EDATU,        "Schedule line date
              INCO1 TYPE INCO1,        "Incoterms
              LFGSA TYPE STRING,       "Overall delivery status of
              LIFSP TYPE STRING,       "Line Item Block
              LIFSK TYPE STRING,       "Header block
              SPSTG TYPE STRING,       "Overall blocked status
              WERKS TYPE WERKS_EXT,    "Plant (Own or External)
           END OF TP_DISP.
    *& INTERNAL TABLES                                                     *
    Internal Tables used for Data Selection
    DATA: T_VBAK TYPE STANDARD TABLE OF TP_VBAK WITH HEADER LINE,
          T_VBPA TYPE STANDARD TABLE OF TP_VBPA WITH HEADER LINE,
          T_VBAP TYPE STANDARD TABLE OF TP_VBAP WITH HEADER LINE,
          T_VBKD TYPE STANDARD TABLE OF TP_VBKD WITH HEADER LINE,
          T_VBEP TYPE STANDARD TABLE OF TP_VBEP WITH HEADER LINE,
          T_VBEP1 TYPE STANDARD TABLE OF TP_VBEP WITH HEADER LINE,
          T_VBUP TYPE STANDARD TABLE OF TP_VBUP WITH HEADER LINE,
          T_ADRC TYPE STANDARD TABLE OF TP_ADRC WITH HEADER LINE,
          T_DISPC TYPE STANDARD TABLE OF TP_DISPC WITH HEADER LINE,
          T_DISPP TYPE STANDARD TABLE OF TP_DISPP WITH HEADER LINE,
          T_DISP TYPE STANDARD TABLE OF TP_DISP WITH HEADER LINE.
    {23-8-2007
    DATA: T_VBUK TYPE STANDARD TABLE OF TP_VBUK WITH HEADER LINE,
          T_TVLST TYPE STANDARD TABLE OF TP_TVLST WITH HEADER LINE,
          T_TVLST1 TYPE STANDARD TABLE OF TP_TVLST WITH HEADER LINE,
          T_VBFA TYPE STANDARD TABLE OF TP_VBFA WITH HEADER LINE.
                Variables used for ALV Display                           *
    DATA:
          W_REPID TYPE SY-REPID,               " Report name
          W_POS   TYPE I VALUE 0,              " Column position indicator
          W_LAYOUT TYPE SLIS_LAYOUT_ALV,       " Layout
          W_DATUM(10) TYPE C,                  " Run date
          W_TIME(8)   TYPE C.                  " Run time
                Tables used for ALV Display                              *
    DATA  :   T_GROUP TYPE SLIS_T_SP_GROUP_ALV WITH HEADER LINE,
                                                 "Grouping of field
              T_SORT TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE,
                                                 "sorting of the field
              T_FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
                                                " Field description
              T_TOP TYPE SLIS_T_LISTHEADER.      " Header for the ALV
                Work Area used for ALV Display
    DATA : WA_TOP LIKE LINE OF T_TOP.            " Work Area for Header
    *& SELECTION SCREEN                                                    *
    Selection
    SELECTION-SCREEN BEGIN OF BLOCK B01 WITH FRAME TITLE TEXT-T01.
    "Sales Organization details
    SELECT-OPTIONS: S_VKORG FOR VBAK-VKORG OBLIGATORY.
    "Sales Organization
    SELECT-OPTIONS: S_VTWEG FOR VBAK-VTWEG .
    "Distribution Channel
    SELECT-OPTIONS: S_KUNNR1 FOR VBPA-KUNNR .             "CS Rep Number
    SELECT-OPTIONS: S_WERKS FOR VBAP-WERKS.               "Plant
    SELECTION-SCREEN END OF BLOCK B01.
    SELECTION-SCREEN BEGIN OF BLOCK B02 WITH FRAME TITLE TEXT-T02.
    "Additional Selections
    SELECT-OPTIONS: S_KUNNR2 FOR VBPA-KUNNR .      "Bill to party
    SELECT-OPTIONS: S_KUNNR3 FOR VBPA-KUNNR .      "Ship to party
    SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN .       "Saler Order
    SELECT-OPTIONS: S_MATNR FOR VBAP-MATNR .       "Material Number
    SELECT-OPTIONS: S_KDMAT FOR VBAP-KDMAT .       "Customer Material Number
    SELECT-OPTIONS: S_AUART FOR VBAK-AUART .       "Sales Order Type
    SELECTION-SCREEN END OF BLOCK B02.
    SELECTION-SCREEN BEGIN OF BLOCK B03 WITH FRAME TITLE TEXT-T03.
    "Date Selection
    SELECT-OPTIONS: S_ERDAT FOR VBAK-ERDAT OBLIGATORY.
    "Order Creation Date
    PARAMETER: P_PLANT AS CHECKBOX.                 "Backorder Plant
    PARAMETER: P_CSREP AS CHECKBOX.                 "Backorder CSREP number
    SELECTION-SCREEN END OF BLOCK B03.
    *& AT SELECTION SCREEN                                                 *
    *Validation Sales Organisation
    AT SELECTION-SCREEN ON S_VKORG.
      IF NOT S_VKORG[] IS INITIAL.
        SELECT VKORG UP TO 1 ROWS FROM TVKO
        BYPASSING BUFFER
        INTO S_VKORG
        WHERE VKORG IN S_VKORG.
        ENDSELECT.
        IF SY-SUBRC NE 0.
          MESSAGE E000 WITH TEXT-E01.
          "Enter a valid Sales Organization
        ENDIF.
      ENDIF.
    *Validation Distribution Channel
    AT SELECTION-SCREEN ON S_VTWEG.
      IF NOT S_VTWEG[] IS INITIAL.
        SELECT VTWEG UP TO 1 ROWS FROM TVTW
         BYPASSING BUFFER
      INTO S_VTWEG
       WHERE VTWEG IN S_VTWEG.
        ENDSELECT.
        IF SY-SUBRC NE 0.
          MESSAGE E000 WITH TEXT-E02.
          "Enter a valid Distribution channel
        ENDIF.
      ENDIF.
    *Validation Customer service rep number
    AT SELECTION-SCREEN ON S_KUNNR1.
      IF NOT S_KUNNR1[] IS INITIAL.
        SELECT KUNNR UP TO 1 ROWS FROM KNA1
        INTO S_KUNNR1
        WHERE KUNNR IN S_KUNNR1.
        ENDSELECT.
        IF SY-SUBRC NE 0.
          MESSAGE E000 WITH TEXT-E03.
          "Enter a valid Customer Service rep number
        ENDIF.
      ENDIF.
    *Validation Plant
    AT SELECTION-SCREEN ON S_WERKS.
      IF NOT S_WERKS[] IS INITIAL.
        SELECT WERKS UP TO 1 ROWS
        FROM T001W
        INTO S_WERKS
        BYPASSING BUFFER
        WHERE WERKS IN S_WERKS.
        ENDSELECT.
        IF SY-SUBRC NE 0.
          MESSAGE E000 WITH TEXT-E04.  "Enter a valid Plant
        ENDIF.
      ENDIF.
    *Validation Bill to number
    AT SELECTION-SCREEN ON S_KUNNR2.
      IF NOT S_KUNNR2[] IS INITIAL.
        SELECT KUNNR UP TO 1 ROWS FROM KNA1
        INTO S_KUNNR2
        WHERE KUNNR IN S_KUNNR2.
        ENDSELECT.
        IF SY-SUBRC NE 0.
          MESSAGE E000 WITH TEXT-E05.  "Enter a valid Bill to number
        ENDIF.
      ENDIF.
    *Validation Ship to Number
    AT SELECTION-SCREEN ON S_KUNNR3.
      IF NOT S_KUNNR3[] IS INITIAL.
        SELECT KUNNR UP TO 1 ROWS FROM KNA1
        INTO S_KUNNR3
        WHERE KUNNR IN S_KUNNR3.
        ENDSELECT.
        IF SY-SUBRC NE 0.
          MESSAGE E000 WITH TEXT-E06.  "Enter a valid Ship to number
        ENDIF.
      ENDIF.
    *Validation Order Number
    AT SELECTION-SCREEN ON S_VBELN.
      IF NOT S_VBELN[] IS INITIAL.
        SELECT VBELN UP TO 1 ROWS FROM VBUK
        INTO S_VBELN
        WHERE VBELN IN S_VBELN.
        ENDSELECT.
        IF SY-SUBRC NE 0.
          MESSAGE E000 WITH TEXT-E07.  "Enter a valid Order number
        ENDIF.
      ENDIF.
    *Validation Material Number
    AT SELECTION-SCREEN ON S_MATNR.
      IF NOT S_MATNR[] IS INITIAL.
        SELECT MATNR UP TO 1 ROWS FROM MARA
        INTO S_MATNR
        WHERE MATNR IN S_MATNR.
        ENDSELECT.
        IF SY-SUBRC NE 0.
          MESSAGE E000 WITH TEXT-E08.  "Enter a valid Material number
        ENDIF.
      ENDIF.
    *Validation Customer Material Number
    AT SELECTION-SCREEN ON S_KDMAT.
      IF NOT S_KDMAT[] IS INITIAL.
        SELECT KDMAT UP TO 1 ROWS
        FROM KNMT
        INTO S_KDMAT
        WHERE VKORG IN S_VKORG AND
              VTWEG IN S_VTWEG AND
              KDMAT IN S_KDMAT.
        ENDSELECT.
        IF SY-SUBRC NE 0.
          MESSAGE E000 WITH TEXT-E09.
          "Enter a valid Customer Material number
        ENDIF.
      ENDIF.
    *Validation Salea order type
    AT SELECTION-SCREEN ON S_AUART.
      IF NOT S_AUART[] IS INITIAL.
        SELECT AUART UP TO 1 ROWS FROM TVAK
        INTO S_AUART
        BYPASSING BUFFER
        WHERE AUART IN S_AUART.
        ENDSELECT.
        IF SY-SUBRC NE 0.
          MESSAGE E000 WITH TEXT-E10.
          "Enter a valid Sales Order type
        ENDIF.
      ENDIF.
    *Validation for Plant / CS rep .
    AT SELECTION-SCREEN .
      IF NOT ( ( P_PLANT = C_X ) OR ( P_CSREP = C_X ) ).
        MESSAGE E000 WITH TEXT-E12.  "Choose the Plant or CSrep
      ENDIF.
      IF  ( P_PLANT = C_X ) AND S_WERKS IS INITIAL.
        MESSAGE E000 WITH TEXT-E13.  "Enter Plant
      ENDIF.
      IF  ( P_CSREP = C_X ) AND S_KUNNR1 IS INITIAL.
        MESSAGE E000 WITH TEXT-E14. " Enter CSREP number
      ENDIF.
    *& START OF SELECTION                                                  *
    START-OF-SELECTION.
    Clear Work Areas/Variables and Clear/Refresh Internal Tables
      PERFORM CLEAR_REFRESH.
    Selection of Data as per inputs
      PERFORM DATA_SELECTION.
    Populate Internal table for display
      PERFORM DATA_FILL_FOR_DISPLAY.
    *& END OF SELECTION                                                  *
    END-OF-SELECTION.
      IF NOT T_DISP[] IS INITIAL.
    *Populating the field catalog for ALV Display if plant and csrep is
    *checked.
        PERFORM POPULATE_FIELD_CATALOG.
        PERFORM DISPLAY.
      ELSEIF T_DISPP[] IS NOT INITIAL.
    *Populating the field catalog for ALV Display if plant is checked.
        PERFORM POPULATE_FIELD_CATALOG.
        PERFORM DISPLAY.
      ELSEIF T_DISPC[] IS NOT INITIAL.
    *Populating the field catalog for ALV Display if csrep is checked.
        PERFORM POPULATE_FIELD_CATALOG.
        PERFORM DISPLAY.
      ELSE.
        MESSAGE I000 WITH TEXT-E15. "No Data found for Selection Criteria
      ENDIF.
    Clear Work Areas/Variables and Clear/Refresh Internal Tables
      PERFORM CLEAR_REFRESH.
    *&      Form  CLEAR_REFRESH
          Clear Work Areas/Variables and Clear/Refresh Internal Tables
    FORM CLEAR_REFRESH .
    Clear Variables/Work Areas/Internal Tables
      CLEAR: W_REPID,
             W_POS,
             W_LAYOUT,
             W_DATUM,
             W_TIME,
             T_VBAK,
             T_VBKD,
             T_VBPA,
             T_VBAP,
             T_VBEP,
             T_VBUP,
             T_DISPC,
             T_DISPP,
             T_DISP,
             T_VBUK,
             T_TVLST,
             T_TVLST1.
    Refresh Internal Tables
      REFRESH: T_VBAK,
               T_VBKD,
               T_VBPA,
               T_VBAP,
               T_VBEP,
               T_VBUP,
               T_DISPC,
               T_DISPP,
               T_DISP,
               T_VBUK,
               T_TVLST,
               T_TVLST1.
    ENDFORM.                    " CLEAR_REFRESH
    *&      Form  DATA_SELECTION
          Selection of Data as per inputs
    FORM DATA_SELECTION .
    *Obtain Sales and distribution document number,Date on which the record
    *was created
    *Sales document type,Delivery block,Sales organisation,
    Distribution channel based on selection criteria
      SELECT VBELN                            "Sales and distribution Doc no
             ERDAT
             "Date on which the record was created
             AUART                            "Sales document type
             LIFSK                            "Delivery block
             VKORG                            "Sales organisation
             VTWEG                            "Distribution channel
             FROM VBAK
             INTO TABLE T_VBAK
             WHERE VBELN IN S_VBELN AND
                   ERDAT IN S_ERDAT AND
                   AUART IN S_AUART AND
                   VKORG IN S_VKORG AND
                   VTWEG IN S_VTWEG.
      IF SY-SUBRC EQ 0.
        SORT T_VBAK BY VBELN .
    *Obtain Sales document ,Sales document item,Material Number,Material
    *number used by customer
    Safer point ,Plant (Own or External),Shipping point /Receiving point
    Net price based on selection criteria
        SELECT A~VBELN        "Sales document
               A~POSNR        "Sales document item
               MATNR        "Material Number
               PSTYV        "Sales document item category
               KDMAT        "Material number used by customer
               VRKME        "Sales unit
               WERKS        "Plant (Own or External)
               VSTEL        "Shipping point /Receiving point
               NETPR        "Net price
    *MOD02 {
               NETWR
    *}MOD02
               WAERK        "Target outline doc currency
               FROM  VBAP AS A JOIN VBUP AS B
               ON ( AVBELN = BVBELN
                   AND APOSNR = BPOSNR )
               INTO TABLE T_VBAP
               FOR ALL ENTRIES IN T_VBAK
               WHERE A~VBELN = T_VBAK-VBELN AND
                     A~MATNR IN S_MATNR AND
                     A~PSTYV NE C_TAPA AND
                     A~KDMAT IN S_KDMAT AND
                     A~WERKS IN S_WERKS AND
                     A~ABGRU EQ SPACE AND
                     B~LFSTA NE 'C'.
        IF SY-SUBRC EQ 0.
          SORT T_VBAP BY VBELN POSNR.
        ENDIF.
       SELECT VBELV
              POSNV
              FROM VBFA
              INTO TABLE T_VBFA
              FOR ALL ENTRIES IN T_VBAP
              WHERE VBELV = T_VBAP-VBELN
              AND POSNV = T_VBAP-POSNR
              AND VBTYP_N = 'J'.
       IF SY-SUBRC = 0.
         SORT T_VBFA BY VBELV POSNV.
         LOOP AT T_VBAP.
    *READ TABLE T_VBFA WITH KEY VBELV = T_VBAP-VBELN POSNV = T_VBAP-POSNR.
           IF SY-SUBRC = 0.
             DELETE T_VBAP.
           ENDIF.
         ENDLOOP.
       ENDIF.
    { 23-8-2007
        SELECT LIFSP
               VTEXT
               FROM TVLST
               INTO TABLE T_TVLST
               FOR ALL ENTRIES IN T_VBAK
               WHERE SPRAS EQ C_E AND
                     LIFSP = T_VBAK-LIFSK.
        IF SY-SUBRC EQ 0.
          SORT T_TVLST BY LIFSP.
        ENDIF.
    *Obtain Sales and distribution document number,Item number of the SD
    *document ,Incoterms,Terms of payment key,Customer purchase order number
    *based on selection criteria
        SELECT VBELN                 "Sales and distribution document number
               POSNR                 "Item number of the SD document
               INCO1                 "Incoterms
               ZTERM                 "Terms of payment key
               BSTKD                 "Customer purchase order number
               FROM VBKD INTO TABLE T_VBKD
               FOR ALL ENTRIES IN T_VBAK
               WHERE VBELN = T_VBAK-VBELN.
        IF SY-SUBRC EQ 0.
          SORT T_VBKD BY VBELN .
        ENDIF.
    *Obtain Sales document,Sales Document Item,Schedule line,Schedule line
    *data, Order quantity in sales unit,Confirmed quantity,Goods issue date,
    *Schedule line blocked for delivery based on selection criteria
        SELECT VBELN                    "Sales document
                POSNR                   "Sales Document Item
                ETENR                   "Schedule line
                EDATU                   "Schedule line data
                CMENG                   "Order quantity in sales unit
                BMENG                   "Confirmed quantity
                LMENG
                WADAT                   "Goods issue date
                LIFSP                   "Schedule line blocked for delivery
                FROM VBEP INTO TABLE T_VBEP
                FOR ALL ENTRIES IN T_VBAK
                WHERE VBELN = T_VBAK-VBELN AND
                      ETENR = C_0001.
        IF SY-SUBRC EQ 0.
          SORT T_VBEP BY VBELN POSNR ETENR.
    { 23-8-2007
          SELECT LIFSP
                 VTEXT
                 FROM TVLST
                 INTO TABLE T_TVLST1
                 FOR ALL ENTRIES IN T_VBEP
                 WHERE SPRAS EQ C_E AND
                       LIFSP = T_VBEP-LIFSP.
          IF SY-SUBRC EQ 0.
            SORT T_TVLST1 BY LIFSP.
          ENDIF.
        ENDIF.
        SELECT VBELN                    "Sales document
                    POSNR                   "Sales Document Item
                    ETENR                   "Schedule line
                    EDATU                   "Schedule line data
                    CMENG                   "Order quantity in sales unit
                    BMENG                   "Confirmed quantity
                    LMENG
                    WADAT                   "Goods issue date
                    LIFSP
                    "Schedule line blocked for delivery
                    FROM VBEP INTO TABLE T_VBEP1
                    FOR ALL ENTRIES IN T_VBAK
                    WHERE VBELN = T_VBAK-VBELN .
        IF SY-SUBRC EQ 0.
          SORT T_VBEP1 BY VBELN POSNR .
        ENDIF.
    { 23-8-2007
        SELECT    VBELN    "Sales and Distribution Document Number
                  SPSTG    "Overall blocked status
    *MOD02 {
                  CMGST
    *}MOD02
            FROM VBUK
            INTO TABLE T_VBUK
            FOR ALL ENTRIES IN T_VBAK
           WHERE VBELN = T_VBAK-VBELN
           AND ( CMGST = 'A' OR CMGST = 'D' ).
        IF SY-SUBRC EQ 0.
          SORT T_VBUK BY VBELN .
        ENDIF.
    *Obtain Sales and distribution Doc no,Item number of the SD document
    Overall delivery status of item
        SELECT    VBELN    "Sales and distribution Doc no
                  POSNR    "Item number of the SD document
                  LFGSA    "Overall delivery status of item
            FROM VBUP
            INTO TABLE T_VBUP
            FOR ALL ENTRIES IN T_VBAK
           WHERE VBELN = T_VBAK-VBELN.
        IF SY-SUBRC EQ 0.
          SORT T_VBUP BY VBELN POSNR.
        ENDIF.
    *Obtain Sales and distribution document number,Partner function
    Customer Number 1,address based on selection criteria
        SELECT    VBELN   "Sales and distribution Doc no
                  PARVW   " Patner function
                  KUNNR   "Customer No1
                  ADRNR   "address
                    FROM VBPA
                    INTO TABLE T_VBPA
                    FOR ALL ENTRIES IN T_VBAP
                   WHERE VBELN = T_VBAP-VBELN AND
                        ( ( KUNNR IN S_KUNNR1 ) OR
                         ( KUNNR IN S_KUNNR2 )  OR
                          ( KUNNR IN S_KUNNR3 ) ) AND
                           ( ( PARVW = C_ZR ) OR
                             ( PARVW = C_BP ) OR
                             ( PARVW = C_SH ) ).
        IF SY-SUBRC EQ 0.
          SORT T_VBPA BY VBELN PARVW.
          IF NOT T_VBPA[] IS INITIAL.
    *Obtain  Address number ,name
            SELECT  ADDRNUMBER  "Address number
                    DATE_FROM   "Date valid from
                    NATION      "International address version ID
                    NAME1        "name
              FROM ADRC
              INTO TABLE T_ADRC
              FOR ALL ENTRIES IN T_VBPA
              WHERE ADDRNUMBER = T_VBPA-ADRNR.
            IF SY-SUBRC EQ 0.
              SORT T_ADRC BY ADDRNUMBER.
            ENDIF.
          ENDIF.
        ELSE.
          MESSAGE I000 WITH TEXT-S02."No Data For the Entered CS rep number
          STOP.
        ENDIF.
      ELSE.
        MESSAGE I000 WITH TEXT-S01.
        "No data found for the selection criteria
        STOP.
      ENDIF.
    ENDFORM.                    " DATA_SELECTION
    *&      Form  DATA_FILL_FOR_DISPLAY
          Populate Internal table for display
    FORM DATA_FILL_FOR_DISPLAY .
      DATA: L_NETPR TYPE NETPR.    "For net amount
      DATA: L_DATE TYPE EDATU.     "For Date Field
      DATA: L_WMENG TYPE WMENG.    "For Confirmed Quantity
      DATA: L_BMENG TYPE BMENG.    "For Delivered Quantity
      DATA : L_LAST_DATE TYPE EDATU.
      DATA : W_FG TYPE C.
      DATA : L_TABIX TYPE SY-TABIX.
      DATA: L_CNT TYPE I,
            L_NETWR TYPE NETWR.
    *If plant and csrep are selected.
      IF ( ( P_PLANT = C_X ) AND ( P_CSREP = C_X ) ).
        LOOP AT T_VBAP.
          CLEAR W_FG.
          CLEAR L_CNT.
    *MOD02 {
          READ TABLE T_VBUK WITH KEY VBELN = T_VBAP-VBELN.
          IF SY-SUBRC = 0.
    *}MOD02
            LOOP AT T_VBEP1 WHERE VBELN = T_VBAP-VBELN AND POSNR =
            T_VBAP-POSNR.
              L_CNT = L_CNT + 1.
              IF L_LAST_DATE IS NOT INITIAL AND W_FG NE 'X'.
                IF L_LAST_DATE NE T_VBEP1-WADAT.
                  W_FG = 'X'.
                ENDIF.
              ENDIF.
              L_LAST_DATE = T_VBEP1-WADAT.
            ENDLOOP.
            IF L_CNT = 1 AND T_VBEP1-BMENG = 0.
              W_FG = 'X'.
            ENDIF.
            IF W_FG = 'X'.
              READ TABLE T_VBEP WITH KEY VBELN = T_VBAP-VBELN
                                         POSNR = T_VBAP-POSNR
                                          BINARY SEARCH.
              IF SY-SUBRC EQ 0.
    *Move Order quantity in sales unit to final internal table
                MOVE T_VBEP-WMENG TO T_DISP-WMENG.
                MOVE T_VBEP-WADAT TO T_DISP-WADAT1.
    *Move Goods issue date to final internal table
                MOVE T_VBEP-EDATU TO T_DISP-WADAT.
    { 23-8-2007
                READ TABLE T_TVLST1 WITH KEY LIFSP = T_VBEP-LIFSP
                                          BINARY SEARCH.
                IF SY-SUBRC EQ 0.
                  CONCATENATE T_VBEP-LIFSP
                                  T_TVLST1-VTEXT
                                  INTO T_DISP-LIFSP
                                  SEPARATED BY SPACE.
                ENDIF.
    *Move the Schedule line blocked for delivery
    to final internal table.
              ENDIF.
    *LOOP AT T_VBEP1 WHERE VBELN = T_VBAP-VBELN AND POSNR = T_VBAP-POSNR.
              LOOP AT T_VBEP1 WHERE VBELN = T_VBAP-VBELN AND POSNR =
              T_VBAP-POSNR.
                L_WMENG = T_VBEP1-WMENG + L_WMENG.
                L_BMENG = T_VBEP1-BMENG + L_BMENG.
           IF NOT L_DATE IS INITIAL.
             IF ( L_DATE < T_VBEP1-EDATU ).
               L_DATE = T_VBEP1-EDATU.
             ENDIF.
           ELSE.
             L_DATE = T_VBEP1-EDATU.
           ENDIF.
                AT END OF POSNR.
                  READ TABLE T_VBEP1 INDEX SY-TABIX.
                  IF SY-SUBRC = 0.
                    L_DATE = T_VBEP1-EDATU.
                  ENDIF.
                ENDAT.
              ENDLOOP.
              IF T_VBEP1-WMENG EQ T_VBEP1-BMENG.
                T_DISP-LOGIC_1 = 0.
                T_DISP-EDATU = T_VBEP1-EDATU.
              ELSEIF   L_WMENG EQ L_BMENG  .
                T_DISP-EDATU = L_DATE.
                T_DISP-LOGIC_1 = L_WMENG.
              ELSE.
                T_DISP-EDATU = C_BLANK.
                T_DISP-LOGIC_1 = L_WMENG.
              ENDIF.
    *Move the Sales document item to final internal table.
              MOVE T_VBAP-POSNR TO T_DISP-POSNR.
    *Move the Material Number to final internal table.
              MOVE T_VBAP-MATNR TO T_DISP-MATNR.
    *Move the Material number used by customer to final internal table.
              MOVE T_VBAP-KDMAT TO T_DISP-KDMAT.
    *Move the Shipping point to final internal table.
              MOVE T_VBAP-VSTEL TO T_DISP-VSTEL.
    *Move the Sales unit to final internal table.
              PERFORM UNIT1 USING T_VBAP-VRKME CHANGING T_VBAP-VRKME.
              MOVE T_VBAP-VRKME TO T_DISP-VRKME.
              MOVE T_VBAP-VRKME TO T_DISP-VRKME_1.
    *Move the Plant (Own or External) to final internal table.
              MOVE T_VBAP-WERKS TO T_DISP-WERKS.
              MOVE T_VBAP-WAERK TO T_DISP-WAERK.
    *Move the Net price to final internal table.
              IF  T_VBAP-WAERK = C_US   .
                L_NETPR = T_VBAP-NETPR.
                L_NETPR = L_NETPR / 100.
                T_DISP-NETPR = L_NETPR.
                CLEAR L_NETPR.
              ELSE.
                MOVE T_VBAP-NETPR TO T_DISP-NETPR.
              ENDIF.
              CLEAR L_NETPR.
    *MOD02{
              IF  T_VBAP-WAERK = C_US   .
                L_NETWR = T_VBAP-NETWR.
                L_NETWR = L_NETWR / 100.
                T_DISP-NETWR = L_NETWR.
                CLEAR L_NETWR.
              ELSE.
                MOVE T_VBAP-NETWR TO T_DISP-NETWR.
              ENDIF.
              CLEAR L_NETWR.
    *}MOD02
    *READ THE TABLE VBAK TO FETCH Sales Order Number,sales
    *organisation,distribution channel,Document type,Delivery block
              READ TABLE T_VBAK WITH KEY VBELN = T_VBEP-VBELN BINARY SEARCH.
              IF SY-SUBRC EQ 0.
    *Move the Sales order number to final internal table.
                MOVE T_VBAK-VBELN TO T_DISP-VBELN.
                PERFORM DELETE_LEADING_ZEROES CHANGING T_DISP-VBELN.
    *Move the Sales organisation to final internal table.
                MOVE T_VBAK-VKORG TO T_DISP-VKORG.
    *Move the Distribution channel to final internal table.
                MOVE T_VBAK-VTWEG TO T_DISP-VTWEG.
    *Move the Document type to final internal table.
                MOVE T_VBAK-AUART TO T_DISP-AUART.
    {23-8-2007
                READ TABLE T_TVLST WITH KEY LIFSP = T_VBAK-LIFSK
                                            BINARY SEARCH.
                IF SY-SUBRC EQ 0.
                  CONCATENATE T_VBAK-LIFSK
                              T_TVLST-VTEXT
                              INTO T_DISP-LIFSK
                              SEPARATED BY SPACE.
                ENDIF.
              ENDIF.
    *READ THE TABLE VBKD TO FETCH Incoterms,Terms of payment key,Customer
    *purchase order number
              READ TABLE T_VBKD WITH KEY VBELN = T_VBAP-VBELN
                BINARY SEARCH.
              IF SY-SUBRC EQ 0.
    *Move the Customer purchase order number to final internal table.
                MOVE T_VBKD-BSTKD TO T_DISP-BSTKD.
    *Move the Incoterms to final internal table.
                MOVE T_VBKD-INCO1 TO T_DISP-INCO1.
    *Move the Terms of payment to final internal table.
                MOVE T_VBKD-ZTERM TO T_DISP-ZTERM.
              ENDIF.
    { 23-8-2007
              READ TABLE T_VBUK WITH KEY VBELN = T_VBEP-VBELN
              BINARY SEARCH.
              IF SY-SUBRC EQ 0.
                IF T_VBUK-SPSTG EQ SPACE.
                  T_DISP-SPSTG = TEXT-TE1. "Not Blocked
                ELSEIF T_VBUK-SPSTG EQ C_C.
                  T_DISP-SP

  • How to run a program in background?

    Hi abapers,
    I want to run a program in background using sm36 and sm37.But i am not aware of input in that tansaction.So kindly tell me the steps ho run a program in background.
    Regards
    Ansuman

    Hi Ansuman Parhi,
    by useing T-codes
    First go to transaction SM36 to schedule the job.
    When you enter the "Start condition" for job, do as follow.
    Select processing by "Date/Time".
    Enter date as current date.
    Let us say you are scheduling this job today then give date 08/30/2007.
    Check "periodic job" checkbox.
    Hit "periodic value" button and select to run "Daily"
    Also have a look on below thread
    Re: How to run program in background?
    This is how to do it through code
    data: lv_job_name like tbtco-jobname,
    lv_job_nr like tbtco-jobcount,
    lv_job_released type c,
    lv_job_start_sofort type c,
    lv_print_parameters type pri_params.
    lv_job_name = 'Z_test'. " your background program name
    call function 'JOB_OPEN'
    exporting
    jobname = lv_job_name
    importing
    jobcount = lv_job_nr
    exceptions
    cant_create_job = 1
    invalid_job_data = 2
    jobname_missing = 3
    others = 4.
    if syst-subrc = 0.
    *submit job with all the selection screen params...
    submit (lv_job_name)
    with applfile = applfile
    with p_lines = p_lines
    with rfc_dest = rfcdest
    with p_selmtd = lv_selmtd
    with px_shsim = px_shsim
    with px_sherr = px_sherr
    user syst-uname
    via job lv_job_name number lv_job_nr and return.
    if sy-subrc = 0.
    call function 'JOB_CLOSE'
    exporting
    jobcount = lv_job_nr
    jobname = lv_job_name
    strtimmed = 'X'
    importing
    job_was_released = lv_job_released
    exceptions
    cant_start_immediate = 1
    invalid_startdate = 2
    jobname_missing = 3
    job_close_failed = 4
    job_nosteps = 5
    job_notex = 6
    lock_failed = 7
    others = 8.
    if syst-subrc 0.
    message i162(00) with
    'An error occured while closing the background job.'.
    stop.
    endif.
    endif.
    endif.
    skip 1.
    write: / 'Background process', lv_job_name ,
    'called successfully' no-gap.
    write: / 'You can check the job in transaction SM37'.
    Hope it will solve your problem..
    Thanks & Regards
    ilesh 24x7

  • How to run the program in back ground with out selection screen ?

    Hi,
    I want to run the program in back ground but don't have selection screen. How to run this program in back ground
    as program has no selection screen.
    Waiting for quick response.
    Best Regards,
    Padhy
    Moderator message: basic, please search for available information/documentation.
    Edited by: Thomas Zloch on Feb 21, 2011 12:43 PM

    Hi,
    Go to transaction SE38 --> Execute --> Background.
    If your program contains selection screen, you have to pass your input values as variants.

Maybe you are looking for

  • How to show an error if the user enters a value which is not in the dropdown of a form

    Hi All, I have attached the screenshot below and if we look at the field for claimnumber we have a dropdown which can help the users pick the available claimnumbers, but if someone accidentally types in a claimnumber that is not in the system( which

  • Selecting all rows in ALV on a button click

    Hi Experts Hi, I have a dynamic ALV table. I also have a button 'Select All Rows'. On clicking the button I want all the rows in the ALV table selected which is done by using set_selected method at the context node. All the rows in the alv is selecte

  • Problem with the ALV display

    hi guys, while executing my ALV report i had got this error message. You attempted to access an unassigned field symbol (data segment "-1"). This error may occur if - You address a typed field symbol before it has been set with    ASSIGN - You addres

  • Exporting videos for use in PowerPoint

    I have a seven minute video I am trying to export for use in a PowerPoint presentation. Everything plays fine - the video is more grainy that I would have liked - but the titles just show up as black screens. I can still hear the audio but it will ju

  • One billing Doc, Two accounting documents

    HI, all, I just found a billing document associated with 2 idential accounting document(different creation time, 10s minutes apart), our users has no idea how it happened, could any one help why and how to avoid this problem? our vension is ECC6 EHP4