Run bdc program when flat file comes

Hi friends
   I want to schedule my bdc program such that it automatically runs as soon as the flat file comes into application server.
Please help me.
Cheers
Vamshi

HI,
Follow this procedure, it might help you.
In the program, use following logic.
IF SY-BATCH = 'X'. * This is for checking
                               whether   program is set for back ground
                                processing.
open dataset .....
if sy-subrc =0.
process data.
else.
continue.
endif.
if you write this logic, as the background job will be scheduled for repetition at a certain interval thenautomatically the flat file will be checked and when it encounters, SY-SUBRC =0 ,the process starts , else no process will be  done.
Hope this solves the problem.
Reward points if helpful.
Thanks and Regards.
Edited by: Ammavajjala Narayana on May 29, 2008 11:36 AM

Similar Messages

  • 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.

  • Auto run BDC program

    hi,
    I Generated one BDC program. Its running properly. But what our client requirement means when data come in Flat file (TEXT file or Excel file) these BDC program should start automatically. How i will do this auto run functionality. If any one knows about this plz let me inform immediately.
    regards
    bab

    Hi
    That means your BDC program should be schedulated and the job should be submitted by an event (see trx SM64), this event should be triggered if the file is updated.
    Now the problem is to understand how the file is updated, because the program updates the file should trigger the event too.
    If the file is updated by a user, u can schedule your program periodically, and if the files is updated u run the BDC
    Max

  • BDC Uploading from flat file to VA01.

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

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

  • BDC for ME21N (Flat file format)

    Hello,
         I have to write a BDC for ME21N(stock transfer).... Someone pls give me the format of flat file... we need separate files for header and items or only one file is enough??? pls someone send me the format and code......
    my email id is [email protected]
    Thanks in advance...
    Regards,
    Maya.

    Hi
    see this and do accordingly
    REPORT zmm_bdcp_purchaseorderkb02
    NO STANDARD PAGE HEADING LINE-SIZE 255.
    Declaring internal tables *
    *-----Declaring line structure
    DATA : BEGIN OF it_dummy OCCURS 0,
    dummy(255) TYPE c,
    END OF it_dummy.
    *-----Internal table for line items
    DATA : BEGIN OF it_idata OCCURS 0,
    ematn(18), "Material Number.
    menge(13), "Qyantity.
    netpr(11), "Net Price.
    werks(4), "Plant.
    ebelp(5), "Item Number.
    END OF it_idata.
    *-----Deep structure for header data and line items
    DATA : BEGIN OF it_me21 OCCURS 0,
    lifnr(10), "Vendor A/c No.
    bsart(4), "A/c Type.
    bedat(8), "Date of creation of PO.
    ekorg(4), "Purchasing Organisation.
    ekgrp(3), "Purchasing Group.
    x_data LIKE TABLE OF it_idata,
    END OF it_me21.
    DATA : x_idata LIKE LINE OF it_idata.
    DATA : v_delimit VALUE ','.
    DATA : v_indx(3) TYPE n.
    DATA : v_fnam(30) TYPE c.
    DATA : v_count TYPE n.
    DATA : v_ne TYPE i.
    DATA : v_ns TYPE i.
    *include bdcrecx1.
    INCLUDE zmm_incl_purchaseorderkb01.
    Search help for file *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
    program_name = syst-cprog
    dynpro_number = syst-dynnr
    IMPORTING
    file_name = p_file.
    START-OF-SELECTION.
    To upload the data into line structure *
    CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
    filename = p_file
    filetype = 'DAT'
    TABLES
    data_tab = it_dummy.
    Processing the data from line structure to internal tables *
    REFRESH:it_me21.
    CLEAR :it_me21.
    LOOP AT it_dummy.
    IF it_dummy-dummy+0(01) = 'H'.
    v_indx = v_indx + 1.
    CLEAR it_idata.
    REFRESH it_idata.
    CLEAR it_me21-x_data.
    REFRESH it_me21-x_data.
    SHIFT it_dummy.
    SPLIT it_dummy AT v_delimit INTO it_me21-lifnr
    it_me21-bsart
    it_me21-bedat
    it_me21-ekorg
    it_me21-ekgrp.
    APPEND it_me21.
    ELSEIF it_dummy-dummy+0(01) = 'L'.
    SHIFT it_dummy.
    SPLIT it_dummy AT v_delimit INTO it_idata-ematn
    it_idata-menge
    it_idata-netpr
    it_idata-werks
    it_idata-ebelp.
    APPEND it_idata TO it_me21-x_data.
    MODIFY it_me21 INDEX v_indx.
    ENDIF.
    ENDLOOP.
    To open the group *
    PERFORM open_group.
    To populate the bdcdata table for header data *
    LOOP AT it_me21.
    v_count = v_count + 1.
    REFRESH it_bdcdata.
    PERFORM subr_bdc_table USING: 'X' 'SAPMM06E' '0100',
    ' ' 'BDC_CURSOR' 'EKKO-LIFNR',
    ' ' 'BDC_OKCODE' '/00',
    ' ' 'EKKO-LIFNR' it_me21-lifnr,
    ' ' 'RM06E-BSART' it_me21-bsart,
    ' ' 'RM06E-BEDAT' it_me21-bedat,
    ' ' 'EKKO-EKORG' it_me21-ekorg,
    ' ' 'EKKO-EKGRP' it_me21-ekgrp,
    ' ' 'RM06E-LPEIN' 'T'.
    PERFORM subr_bdc_table USING: 'X' 'SAPMM06E' '0120',
    ' ' 'BDC_CURSOR' 'RM06E-EBELP',
    ' ' 'BDC_OKCODE' '/00'.
    MOVE 1 TO v_indx.
    *-----To populate the bdcdata table for line item data
    LOOP AT it_me21-x_data INTO x_idata.
    CONCATENATE 'EKPO-EMATN(' v_indx ')' INTO v_fnam.
    PERFORM subr_bdc_table USING ' ' v_fnam x_idata-ematn.
    CONCATENATE 'EKPO-MENGE(' v_indx ')' INTO v_fnam.
    PERFORM subr_bdc_table USING ' ' v_fnam x_idata-menge.
    CONCATENATE 'EKPO-NETPR(' v_indx ')' INTO v_fnam.
    PERFORM subr_bdc_table USING ' ' v_fnam x_idata-netpr.
    CONCATENATE 'EKPO-WERKS(' v_indx ')' INTO v_fnam.
    PERFORM subr_bdc_table USING ' ' v_fnam x_idata-werks.
    v_indx = v_indx + 1.
    PERFORM subr_bdc_table USING: 'X' 'SAPMM06E' '0120',
    ' ' 'BDC_CURSOR' 'RM06E-EBELP',
    ' ' 'BDC_OKCODE' '/00'.
    ENDLOOP.
    PERFORM subr_bdc_table USING: 'X' 'SAPMM06E' '0120',
    ' ' 'BDC_CURSOR' 'RM06E-EBELP',
    ' ' 'BDC_OKCODE' '=BU'.
    PERFORM bdc_transaction USING 'ME21'.
    ENDLOOP.
    PERFORM close_group.
    End of selection event *
    END-OF-SELECTION.
    IF session NE 'X'.
    *-----To display the successful records
    WRITE :/10 text-001. "Sucess records
    WRITE :/10 SY-ULINE(20).
    SKIP.
    IF it_sucess IS INITIAL.
    WRITE :/ text-002.
    ELSE.
    WRITE :/ text-008, "Total number of Succesful records
    35 v_ns.
    SKIP.
    WRITE:/ text-003, "Vendor Number
    17 text-004, "Record number
    30 text-005. "Message
    ENDIF.
    LOOP AT it_sucess.
    WRITE:/4 it_sucess-lifnr,
    17 it_sucess-tabix CENTERED,
    30 it_sucess-sucess_rec.
    ENDLOOP.
    SKIP.
    *-----To display the erroneous records
    WRITE:/10 text-006. "Error Records
    WRITE:/10 SY-ULINE(17).
    SKIP.
    IF it_error IS INITIAL.
    WRITE:/ text-007. "No error records
    ELSE.
    WRITE:/ text-009, "Total number of erroneous records
    35 v_ne.
    SKIP.
    WRITE:/ text-003, "Vendor Number
    17 text-004, "Record number
    30 text-005. "Message
    ENDIF.
    LOOP AT it_error.
    WRITE:/4 it_error-lifnr,
    17 it_error-tabix CENTERED,
    30 it_error-error_rec.
    ENDLOOP.
    REFRESH it_sucess.
    REFRESH it_error.
    ENDIF.
    CODE IN INCLUDE.
    Include ZMM_INCL_PURCHASEORDERKB01
    DATA: it_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
    DATA: it_MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
    DATA: E_GROUP_OPENED.
    *-----Internal table to store sucess records
    DATA:BEGIN OF it_sucess OCCURS 0,
    msgtyp(1) TYPE c,
    lifnr LIKE ekko-lifnr,
    tabix LIKE sy-tabix,
    sucess_rec(125),
    END OF it_sucess.
    DATA: g_mess(125) type c.
    *-----Internal table to store error records
    DATA:BEGIN OF it_error OCCURS 0,
    msgtyp(1) TYPE c,
    lifnr LIKE ekko-lifnr,
    tabix LIKE sy-tabix,
    error_rec(125),
    END OF it_error.
    Selection screen
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS session RADIOBUTTON GROUP ctu. "create session
    SELECTION-SCREEN COMMENT 3(20) text-s07 FOR FIELD session.
    SELECTION-SCREEN POSITION 45.
    PARAMETERS ctu RADIOBUTTON GROUP ctu. "call transaction
    SELECTION-SCREEN COMMENT 48(20) text-s08 FOR FIELD ctu.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 3(20) text-s01 FOR FIELD group.
    SELECTION-SCREEN POSITION 25.
    PARAMETERS group(12). "group name of session
    SELECTION-SCREEN COMMENT 48(20) text-s05 FOR FIELD ctumode.
    SELECTION-SCREEN POSITION 70.
    PARAMETERS ctumode LIKE ctu_params-dismode DEFAULT 'N'.
    "A: show all dynpros
    "E: show dynpro on error only
    "N: do not display dynpro
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 48(20) text-s06 FOR FIELD cupdate.
    SELECTION-SCREEN POSITION 70.
    PARAMETERS cupdate LIKE ctu_params-updmode DEFAULT 'L'.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 3(20) text-s03 FOR FIELD keep.
    SELECTION-SCREEN POSITION 25.
    PARAMETERS: keep AS CHECKBOX. "' ' = delete session if finished
    "'X' = keep session if finished
    SELECTION-SCREEN COMMENT 48(20) text-s09 FOR FIELD e_group.
    SELECTION-SCREEN POSITION 70.
    PARAMETERS e_group(12). "group name of error-session
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 51(17) text-s03 FOR FIELD e_keep.
    SELECTION-SCREEN POSITION 70.
    PARAMETERS: e_keep AS CHECKBOX. "' ' = delete session if finished
    "'X' = keep session if finished
    SELECTION-SCREEN END OF LINE.
    PARAMETERS:p_file LIKE rlgrap-filename.
    at selection screen *
    AT SELECTION-SCREEN.
    group and user must be filled for create session
    IF SESSION = 'X' AND
    GROUP = SPACE. "OR USER = SPACE.
    MESSAGE E613(MS).
    ENDIF.
    create batchinput session *
    FORM OPEN_GROUP.
    IF SESSION = 'X'.
    SKIP.
    WRITE: /(20) 'Create group'(I01), GROUP.
    SKIP.
    *----open batchinput group
    CALL FUNCTION 'BDC_OPEN_GROUP'
    EXPORTING
    CLIENT = SY-MANDT
    GROUP = GROUP
    USER = sy-uname.
    WRITE:/(30) 'BDC_OPEN_GROUP'(I02),
    (12) 'returncode:'(I05),
    SY-SUBRC.
    ENDIF.
    ENDFORM. "OPEN_GROUP
    end batchinput session *
    FORM CLOSE_GROUP.
    IF SESSION = 'X'.
    *------close batchinput group
    CALL FUNCTION 'BDC_CLOSE_GROUP'.
    WRITE: /(30) 'BDC_CLOSE_GROUP'(I04),
    (12) 'returncode:'(I05),
    SY-SUBRC.
    ELSE.
    IF E_GROUP_OPENED = 'X'.
    CALL FUNCTION 'BDC_CLOSE_GROUP'.
    WRITE: /.
    WRITE: /(30) 'Fehlermappe wurde erzeugt'(I06).
    ENDIF.
    ENDIF.
    ENDFORM. "CLOSE_GROUP
    Start new transaction according to parameters *
    FORM BDC_TRANSACTION USING TCODE TYPE ANY.
    DATA: L_SUBRC LIKE SY-SUBRC.
    *------batch input session
    IF SESSION = 'X'.
    CALL FUNCTION 'BDC_INSERT'
    EXPORTING
    TCODE = TCODE
    TABLES
    DYNPROTAB = it_BDCDATA.
    WRITE: / 'BDC_INSERT'(I03),
    TCODE,
    'returncode:'(I05),
    SY-SUBRC,
    'RECORD:',
    SY-INDEX.
    ELSE.
    REFRESH it_MESSTAB.
    CALL TRANSACTION TCODE USING it_BDCDATA
    MODE CTUMODE
    UPDATE CUPDATE
    MESSAGES INTO it_MESSTAB.
    L_SUBRC = SY-SUBRC.
    WRITE: / 'CALL_TRANSACTION',
    TCODE,
    'returncode:'(I05),
    L_SUBRC,
    'RECORD:',
    SY-INDEX.
    ENDIF.
    Message handling for Call Transaction *
    perform subr_mess_hand using g_mess.
    *-----Erzeugen fehlermappe
    IF L_SUBRC <> 0 AND E_GROUP <> SPACE.
    IF E_GROUP_OPENED = ' '.
    CALL FUNCTION 'BDC_OPEN_GROUP'
    EXPORTING
    CLIENT = SY-MANDT
    GROUP = E_GROUP
    USER = sy-uname
    KEEP = E_KEEP.
    E_GROUP_OPENED = 'X'.
    ENDIF.
    CALL FUNCTION 'BDC_INSERT'
    EXPORTING
    TCODE = TCODE
    TABLES
    DYNPROTAB = it_BDCDATA.
    ENDIF.
    REFRESH it_BDCDATA.
    ENDFORM. "BDC_TRANSACTION
    Form subr_bdc_table *
    text
    -->P_0220 text *
    -->P_0221 text *
    -->P_0222 text *
    FORM subr_bdc_table USING VALUE(P_0220) TYPE ANY
    VALUE(P_0221) TYPE ANY
    VALUE(P_0222) TYPE ANY.
    CLEAR it_bdcdata.
    IF P_0220 = ' '.
    CLEAR it_bdcdata.
    it_bdcdata-fnam = P_0221.
    it_bdcdata-fval = P_0222.
    APPEND it_bdcdata.
    ELSE.
    it_bdcdata-dynbegin = P_0220.
    it_bdcdata-program = P_0221.
    it_bdcdata-dynpro = P_0222.
    APPEND it_bdcdata.
    ENDIF.
    ENDFORM. " subr_bdc_table
    Form subr_mess_hand *
    text *
    -->P_G_MESS text *
    FORM subr_mess_hand USING P_G_MESS TYPE ANY.
    LOOP AT IT_MESSTAB.
    CALL FUNCTION 'FORMAT_MESSAGE'
    EXPORTING
    ID = it_messtab-msgid
    LANG = it_messtab-msgspra
    NO = it_messtab-msgnr
    v1 = it_messtab-msgv1
    v2 = it_messtab-msgv2
    IMPORTING
    MSG = P_G_MESS
    EXCEPTIONS
    OTHERS = 0.
    CASE it_messtab-msgtyp.
    when 'E'.
    it_error-error_rec = P_G_MESS.
    it_error-lifnr = it_me21-lifnr.
    it_error-tabix = v_count.
    APPEND IT_ERROR.
    when 'S'.
    it_sucess-sucess_rec = P_G_MESS.
    it_sucess-lifnr = it_me21-lifnr.
    it_sucess-tabix = v_count.
    APPEND IT_SUCESS.
    endcase.
    ENDLOOP.
    Describe table it_sucess lines v_ns.
    Describe table it_error lines v_ne.
    ENDFORM. " subr_mess_hand
    Regards
    Anji

  • Problem in BDC program when executed using scheduled job

    I have developed a BDC program for J1I5 T-code whcih updates RG1 Register. This is working as expected when run in foreground as well as in background. But it is not giving expected results when scheduled in Job. It is not giving any error message, job is executed without error.
    What can be the problem? pls. help.
    Thanks!
    Prakash

    Hi,
    Thanks for reply.
    I have checked log using SM37, it is not showing any error.
    Log details are as follows...
    Date       Time     Message text                                                                             Message class Message no. Messag
    08.05.2010 11:47:10 Job started                                                                                00           516          S
    08.05.2010 11:47:10 Step 001 started (program ZSDB_J1I5_REG_UPDATE_BDC, variant 1101_1_RMA, user ID STK)      00           550          S
    08.05.2010 11:47:20 Job finished                                                                                00           517          S

  • Compile and run java programs using batch file

    i am using eclipse to run my java programs.How to compile and run those programs using a batch file?

    a) just write a batch file, and add it to the project. When you want to run it, go to a command window and invoke it. (There is probably also a way to invoke it from Eclipse)
    b) if the project is complicated, take a look at ant. Eclispe knows about ant files.

  • 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

  • Bdc - errors in flat file

    hi,
    in BDC,
    after uploading data from flat file,
    how to find if there are any errors in flat file,
    before starting the session.

    Hi,
    You have to create internal tables for all the mandatory fields. see the following code :
    I am giving an example for XK01 Transaction.
    TYPES:BEGIN OF TY_XK01,
          LIFNR(10)      TYPE  C ,          "VENDOR'S ACCOUNT NUMBER
          BUKRS(4)       TYPE  C ,          "COMPANY CODE
          EKORG(4)       TYPE  C ,          "PURCHASING ORGANISATION
          KTOKK(4)       TYPE  C ,          "VENDOR ACCOUNT GROUP
          NAME1(35)      TYPE  C ,                              "NAME1
          SORTL(10)      TYPE  C ,          "SORT FIELD
          STRAS(35)      TYPE  C ,          "STREET
          PSTLZ(10)      TYPE  C ,          "POSTAL CODE
          ORT01(35)      TYPE  C ,          "CITY
          LAND1(3)       TYPE  C ,          "COUNTRY KEY
          REGIO(3)       TYPE  C ,          "REGION
          TIME_ZONE(6)   TYPE  C ,          "ADDRESS TIME ZONE
          LANGU(1)       TYPE  C ,          "LANGUAGE KEY
          TELF1(16)      TYPE  C ,          "TELEPHONE NUMBER
          TELFX(31)      TYPE  C ,          "FAX NUMBER
          SMTP_ADDR(241) TYPE  C ,          "E-MAIL ADDRESS
          URI_SCREEN(132) TYPE  C ,     "UNIFORM RESOURCE LOCATOR
          AKONT(10)      TYPE  C ,          "RECONCILITATION ACCOUNT
          ZUAWA(3)       TYPE  C ,          "KEY FOR SORTING ACCORDING TO ASSIGNMENT NUMBERS
          MINDK(3)       TYPE  C ,          "MINORITY INDICATORS
          ALTKN(10)      TYPE  C ,          "PREVIOUS MASTER RECORD NUMBER
          ZTERM(4)       TYPE  C ,          "TERMS OF PAYMENT KEY
          ZWELS(10)      TYPE  C ,          "LIST OF THE PAYMENT METHODS
          WAERS(5)       TYPE  C ,          "PURCHASE ORDER CURRENCY
          END OF TY_XK01,
    BEGIN OF TY_LIFNR,
         LIFNR(10)  TYPE  C ,
         END OF TY_LIFNR,
         BEGIN OF TY_BUKRS,
         BUKRS(4)  TYPE  C ,
         END OF TY_BUKRS,
         BEGIN OF TY_EKORG,
         EKORG(4)  TYPE  C ,
         END OF TY_EKORG,
         BEGIN OF TY_KTOKK,
         KTOKK(4)  TYPE  C ,
         END OF TY_KTOKK,
         BEGIN OF TY_LAND1,
         LAND1(3)  TYPE  C ,
         END OF TY_LAND1,
         BEGIN OF TY_LANGU,
         LANGU(1)  TYPE  C ,
         END OF TY_LANGU,
         BEGIN OF TY_AKONT,
         AKONT(10) TYPE  C ,
         END OF TY_AKONT,
         BEGIN OF TY_ZUAWA,
         ZUAWA(3)  TYPE  C ,
         END OF TY_ZUAWA,
         BEGIN OF TY_MINDK,
         MINDK(3) TYPE  C ,
         END OF TY_MINDK,
         BEGIN OF TY_WAERS,
         WAERS(5)  TYPE  C ,
         END OF TY_WAERS.
    DATA : I_XK01     TYPE TABLE OF  TY_XK01,     "FOR HOLDING DATA FROM FLAT FILE
           I_SUCCMESG TYPE TABLE OF  TY_MESG,     "FOR SUCCESS RECORDS DETAILS
           I_ERRMESG  TYPE TABLE OF  TY_MESG,     "FOR ERROR RECORDS DETAILS
           I_ERROR TYPE TABLE OF TY_ERROR,
    I_LIFNR TYPE TABLE OF TY_LIFNR,
    I_BUKRS TYPE TABLE OF TY_BUKRS,
    I_EKORG TYPE TABLE OF TY_EKORG,
    I_KTOKK TYPE TABLE OF TY_KTOKK,
    I_LAND1 TYPE TABLE OF TY_LAND1,
    I_LANGU TYPE TABLE OF TY_LANGU,
    I_AKONT TYPE TABLE OF TY_AKONT,
    I_ZUAWA TYPE TABLE OF TY_ZUAWA,
    I_MINDK TYPE TABLE OF TY_MINDK,
    I_WAERS TYPE TABLE OF TY_WAERS,
    I_FINALMESG TYPE TABLE OF TY_ERROR,
    I_MESG TYPE TABLE OF TY_MESG.
    *& WORK AREA DECLARATION
    DATA:  WA_XK01     TYPE TY_XK01,               "FOR HOLDING DATA FROM FLAT FILE
           WA_SUCCMESG TYPE TY_MESG,               "FOR SUCCESS RECORDS DETAILS
           WA_ERRMESG  TYPE TY_MESG,               "FOR ERROR RECORDS DETAILS
           WA_ERROR TYPE TY_ERROR,
    WA_LIFNR TYPE TY_LIFNR,
    WA_BUKRS TYPE TY_BUKRS,
    WA_EKORG TYPE TY_EKORG,
    WA_KTOKK TYPE TY_KTOKK,
    WA_LAND1 TYPE TY_LAND1,
    WA_LANGU TYPE TY_LANGU,
    WA_AKONT TYPE TY_AKONT,
    WA_ZUAWA TYPE TY_ZUAWA,
    WA_MINDK TYPE TY_MINDK,
    WA_WAERS TYPE TY_WAERS,
    WA_MESG TYPE TY_MESG,
    WA_FINALMESG TYPE TY_ERROR.
    INITIALIZATION.
    SELECT LIFNR FROM LFA1 INTO TABLE I_LIFNR.
      SELECT BUKRS FROM T001 INTO TABLE I_BUKRS .
      SELECT EKORG FROM T024E INTO TABLE I_EKORG .
      SELECT KTOKK FROM T077K INTO TABLE I_KTOKK .
      SELECT LAND1 FROM T005 INTO TABLE I_LAND1.
      SELECT SPRAS FROM T002 INTO TABLE I_LANGU.
      SELECT SAKNR FROM SKA1 INTO TABLE I_AKONT .
      SELECT ZUAWA FROM TZUN INTO TABLE I_ZUAWA .
      SELECT MINDK FROM T059M INTO TABLE I_MINDK .
      SELECT WAERS FROM TCURC INTO TABLE I_WAERS.
    LOOP AT I_XK01 INTO WA_XK01.
          TRANSLATE WA_XK01-LIFNR TO UPPER CASE.
          READ TABLE I_LIFNR INTO WA_LIFNR WITH KEY LIFNR = WA_XK01-LIFNR.
          IF SY-SUBRC = 0 .
            CONCATENATE WA_MESG-MESG TEXT-100 WA_XK01-LIFNR TEXT-101  ' , ' INTO WA_MESG-MESG.
          ENDIF.
          TRANSLATE WA_XK01-BUKRS TO UPPER CASE.
          READ TABLE I_BUKRS INTO WA_BUKRS WITH KEY BUKRS = WA_XK01-BUKRS.
          IF SY-SUBRC <> 0 .
            CONCATENATE WA_MESG-MESG  TEXT-102 WA_XK01-BUKRS TEXT-103  ' , ' INTO WA_MESG-MESG.
          ENDIF.
          TRANSLATE WA_XK01-EKORG TO UPPER CASE.
          READ TABLE I_EKORG INTO WA_EKORG WITH KEY EKORG = WA_XK01-EKORG.
          IF SY-SUBRC <> 0 .
            CONCATENATE WA_MESG-MESG TEXT-104    WA_XK01-EKORG  TEXT-103  ',' INTO WA_MESG-MESG.
          ENDIF.
          TRANSLATE WA_XK01-KTOKK TO UPPER CASE.
          READ TABLE I_KTOKK INTO WA_KTOKK WITH KEY KTOKK = WA_XK01-KTOKK.
          IF SY-SUBRC <> 0 .
            CONCATENATE WA_MESG-MESG TEXT-105   WA_XK01-KTOKK  TEXT-103   ',' INTO WA_MESG-MESG.
          ENDIF.
          TRANSLATE WA_XK01-LAND1 TO UPPER CASE.
          READ TABLE I_LAND1 INTO WA_LAND1 WITH KEY LAND1 = WA_XK01-LAND1.
          IF SY-SUBRC <> 0 .
            CONCATENATE WA_MESG-MESG TEXT-106   WA_XK01-LAND1  TEXT-103   ',' INTO WA_MESG-MESG.
          ENDIF.
          TRANSLATE WA_XK01-LANGU TO UPPER CASE.
          READ TABLE I_LANGU INTO WA_LANGU WITH KEY LANGU = WA_XK01-LANGU.
          IF SY-SUBRC <> 0 .
            CONCATENATE WA_MESG-MESG TEXT-107  WA_XK01-LANGU  TEXT-103   ',' INTO WA_MESG-MESG.
          ENDIF.
          READ TABLE I_AKONT INTO WA_AKONT WITH KEY AKONT = WA_XK01-AKONT.
          IF SY-SUBRC <> 0 .
            CONCATENATE WA_MESG-MESG TEXT-108   WA_XK01-AKONT  TEXT-103  ',' INTO WA_MESG-MESG.
          ENDIF.
          READ TABLE I_ZUAWA INTO WA_ZUAWA WITH KEY ZUAWA = WA_XK01-ZUAWA.
          IF SY-SUBRC <> 0 .
            CONCATENATE WA_MESG-MESG TEXT-109    WA_XK01-ZUAWA  TEXT-103   ',' INTO WA_MESG-MESG.
          ENDIF.
          READ TABLE I_MINDK INTO WA_MINDK WITH KEY MINDK = WA_XK01-MINDK.
          IF SY-SUBRC <> 0 .
            CONCATENATE WA_MESG-MESG TEXT-110    WA_XK01-MINDK  TEXT-103   ',' INTO WA_MESG-MESG.
          ENDIF.
          TRANSLATE WA_XK01-WAERS TO UPPER CASE.
          READ TABLE I_WAERS INTO WA_WAERS WITH KEY WAERS = WA_XK01-WAERS.
          IF SY-SUBRC <> 0 .
            CONCATENATE WA_MESG-MESG TEXT-111   WA_XK01-WAERS  TEXT-103   ',' INTO WA_MESG-MESG.
          ENDIF.
    append wa_mesg to err_mesg. 
    endloop.
    I am populating the error messages into workarea using concatenate statement.
    Hope this  solves the problem.
    Reward points if helpful.
    Thanks and Regards,
    Narayana.

  • Running Java Program via bat file

    Hi
    I have a bat file. I have compile the java files and the class files into the same folder.
    I am suppose to double click on the bat file and it is suppose to run (in the same manner as IDE)
    but it only appear the 1st line of the program. Whatever i type, it refuse to budge.
    What should i do to retify the problem?
    I have already set the classpath properly

    Hi
    I just realised that my program can only run halfway on the dos...
    This is my code sample
    try{
                pw = new PrintWriter("TS.log");           
                System.out.println ("hi");
            catch(IOException io){
                io.printStackTrace();
            try {
                StandAloneApplication = true;
                String[] a = new String[1];  
                System.out.println ("hi2");
                Settings settings = Settings.getInstance();
                StringTokenizer letterToken = new StringTokenizer(settings.get("letter"),",");
                Vector <String> v = new Vector<String>();
                while(letterToken.hasMoreTokens()){
                    v.add(letterToken.nextToken());
                String letter[] = v.toArray(new String[v.size()]);
                System.out.println ("hi3");
                DbConnection d = new DbConnection();
                String stocklist = d.getStockList();
                String mainFile ="";
                GenerateSLS sMain = new GenerateSLS("timeSales.sls");                                               
                String sessionID = d.createiFisSession();                      
                System.out.println ("hi4");
                for(int i=0;i<letter.length;i++){
                    System.out.println ("print");
                    mainFile = sMain.start("timeSalesGen"+letter[i]+".sls",d.getStockList(letter[i]+"%.SI"),sessionID);
                    a[0] = mainFile;       
                    staticArguments = a;       
                    Viewer viewerMain = new TSMainCapture();       
                    viewerMain.init();          
                    viewerMain.start();it stops printing after "hi4"
    btw, I have tried to run this on the bat file again.
    IDE side retest, re-compile and rerun, work well
    Pls help
    Thanks.
    Lots of appreciation

  • Plz send simple bdc  code with flat file which is executable

    plz send a simple code for upload bdc with flat file which is executable.

    plz send a simple code for upload bdc with flat file which is executable.

  • How to get the erroe message, if i run java program using .bat file

    Hi,
    I have a java file which accepts two inputs as command line argument. I want to make this pgm a tool. So have created a *.bat file which has the following command
    java myprogram arg1 arg2
    I'm gonna share this program with others. So i'll keep the class file and the .bat file in a commaon folder. All the users have to do is, edit the .bat file to give his/her args and run the .bat file. The pbm is, if the user input is not valid, I have put displays in the pgm to show it.
    But if i run thru .bat, I'm not getting the error message or I don't know where it is getting displayed.
    Can anyone help me with this ?
    Thanks,
    Mary

    When i run from the console, I can see the output.
    But, when i double click on the .bat file from the
    folder, it runs fine and i couldn't see the output.
    nullThat's because the error message is printed, and then the console is closed. The message is there but you need to read really really fast :)

  • Running Java Programs when JDBC libraries in classpath

    Hi I am running NT Server 4.0 SP5 and Oracle 8i.
    I have compiled several Java Programs, some of which use Oracles
    JDBC drivers. When I try to run any of the programs I get the
    complaint "Can't find class X", where X is the class which
    contains main(..) and the name of the file. If I delete the
    references to BOTH (leaving one does nothing) classes111.zip and
    nlscharset11.zip in the classpath, the programs, which don't use
    JDBC run fine, but the ones which do use JDBC and need those
    packages complain. If I put the classes which need the Oracle
    JDBC drivers in the same directory as the classes111.zip and
    nlscharset11.zip (with an empty classpath) I get the first error
    "Can't find class X", where X is the class which contains
    main(..) and the name of the file. I have tried these
    combinations with four different Java compliers and VM and always
    get the same errors.
    Thanks, Charlie
    null

    set PATH=%PATH%;C:\ORAWIN95\BIN
    set
    PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\jdk1.3\bin;C:\ORA
    IN95\BIN
    set
    CLASSPATH=C:\jdk1.3\lib\jvm.lib;C:\jdk1.3\lib\tools.jar
    set
    CLASSPATH=C:\project;C:\tomcat\common\lib\servlet.jar
    set CLASSPATH=C:\tomcat\bin\jasper.jar
    set CLASSPATH=C:\jsdk2.1\servlet.jar
    set CLASSPATH=C:\jdk1.3\bin;C:\projectBy the way, after running these commands your classpath will ONLY contain C:\jdk1.3\bin;C:\project, because that is the last thing you set it to.
    To add to your classpath, you need to do something like:
    set CLASSPATH=%CLASSPATH%;C:\jdk1.3\bin;C:\project
    which works because %CLASSPATH% evaluates to the current value of CLASSPATH.

  • Automatically run an action when a file opens

    select all
    pathfinder | trim
    save
    I created an action and assigned it to F2.
    Will someone share how I can have that action run whenever a files opens, or write a javascript for me.
    This is for Illustrator CS4
    Thanks
    Cedric

    Sorry about that, here is the current code:
    //WHEN SAVING JPG
    var jpgopts = new JPEGSaveOptions();
    jpgopts.embedProfile = true;
    jpgopts.formatOptions = FormatOptions.STANDARDBASELINE;
    jpgopts.matte = MatteType.NONE;
    jpgopts.quality = 10;
    //WHEN SAVING PSD
    psdOpts = new PhotoshopSaveOptions();
    psdOpts.embedColorProfile = true;
    psdOpts.alphaChannels = true;
    psdOpts.layers = true;
    if (app.documents.length > 0) {
    var myDocument = app.activeDocument;
    var theName= myDocument.name.match(/(.*)\.[^\.]+$/)[1];
    var thePath = myDocument.path;
    var theLayer = myDocument.layerSets["Sizes"].artLayers.getByName ("11x11");
    // check if layer is smart object;
    if (theLayer.kind != "LayerKind.SMARTOBJECT") {alert ("selected layer is not a smart object")}
    else {
    // select files;
    if ($.os.search(/windows/i) != -1)
        //var theFiles = File.openDialog ("please select files", "*.png;*.jpg;*.psd;*.tif", true)   
        var folder = new Folder("F:/Input");
        var theFiles = folder.getFiles(/\.(png|jpg|tif|eps|psd)$/i)
    else {var theFiles = File.openDialog ("please select files", getFiles, true)};
    if (theFiles) {
    // work through the array;
      for (var m = 0; m < theFiles.length; m++) {
    // replace smart object;
    theLayer = replaceContents (theFiles[m], theLayer);
    var theNewName = theFiles[m].name.match(/(.*)\.[^\.]+$/)[1];
    myDocument.saveAs((new File("F:/Output/" + theNewName + ".jpg")),jpgopts,true);

  • Why isn't RUN an option when downloading files?

    When I download executable files (such as an upgrade for Firefox), a box appears that asks what I want to do with the file: Save or Cancel. There is never a Run option. Why?
    Every time I download something, I need to use Internet Explorer.

    Think about it for starters. If a newer computer user were to run a Iamreallyatrojan.exe with Firefox, who are they going to likely blame, Mozilla or themselves? is another reason besides the should be obvious security.
    Even IE downloads it first before running it without doing any scanning first.

Maybe you are looking for