BAPI for fb65

Hi ,
I want to call transaction FB65 for the company code , vendor , amount and GL_account.
Is there any BAPI which i can use for this purpose.
Thanks in advance.

sample code using RFBIBL00
TABLES : BGR00,    " Batch Input Structure for Session Data
         BBKPF,    " Doc Hdr for Accntng Doc (Batch Input Structure)
         BBSEG,    " Accounting Document Segment (Batch Input Structure)
         USR01.
Internal Table and structure Declarations                           *
Internal table to hold input file data
DATA:BEGIN OF IT_INFILE OCCURS 0.
        INCLUDE STRUCTURE Z0FI_AP_FADS_TO_SAP. "Input file format
DATA:ERROR(1) TYPE C,                          "error indicator
END OF IT_INFILE.
Internal table to hold input file data
DATA:BEGIN OF IT_ERRORS OCCURS 0.
        INCLUDE STRUCTURE Z0FI_AP_FADS_TO_SAP. "Input file format
DATA: MSG(200) TYPE C,                         "message
END OF IT_ERRORS.
Internal table to hold GL data
DATA:BEGIN OF IT_GL OCCURS 0,
SAP_GL_ACCOUNT  LIKE ZFGLT_GL_PRI_SUB-SAP_GL_ACCOUNT, "G/L Account
LGCY_SYSTEM     LIKE ZFGLT_GL_PRI_SUB-LGCY_SYSTEM,    "Legacy System
LGCY_PRIME_ACCT LIKE ZFGLT_GL_PRI_SUB-LGCY_PRIME_ACCT,"Legacy Account
LGCY_SUB_ACCT   LIKE ZFGLT_GL_PRI_SUB-LGCY_SUB_ACCT,  "Legacy Sub Acct
END OF IT_GL.
Internal table to hold cost center data
DATA:BEGIN OF IT_COSTCTR OCCURS 0,
COST_OBJECT    LIKE ZFCFT_CTR_DPT_LG-COST_OBJECT,     "Cost center
LGCY_LDGR      LIKE ZFCFT_CTR_DPT_LG-LGCY_LDGR,       "Legacy ledger
LGCY_DEPT      LIKE ZFCFT_CTR_DPT_LG-LGCY_DEPT,       "Legacy Department
END OF IT_COSTCTR.
Internal table to hold vendor data
DATA:BEGIN OF IT_LFA1 OCCURS 0,
LIFNR TYPE LIFNR,                                     "Vendor no
BUKRS TYPE BUKRS,                                     "Company code
STCD1 TYPE STCD1,                                           "Tax ID1
STCD2 TYPE STCD2,                                           "Tax ID2
END OF IT_LFA1.
Internal table to hold Primary Sub Acct data
DATA:BEGIN OF IT_SUBACCT OCCURS 0,
PRYACT1(10) TYPE C,                                    "Pry sub Acct1
PRYACT2(10) TYPE C,                                    "Pry sub Acct2
END OF IT_SUBACCT.
Internal table to hold ledger data
DATA:BEGIN OF IT_LEDGER OCCURS 0,
LGR_ID(4) TYPE C,                                      "Ledger ID
DEPT(4) TYPE C,                                        "Department
END OF IT_LEDGER.
Internal table to hold tax id
DATA:BEGIN OF IT_TAXID OCCURS 0,
TAXID1(16) TYPE C,                                          "Tax ID1
TAXID2(11) TYPE C,                                          "Tax ID2
END OF  IT_TAXID.
Internal table to hold line amounts sum data
DATA:BEGIN OF IT_SUM OCCURS 0,
TAX_ID_NO(10) TYPE C,                                  "Tax Id No
INVOICE_NO(12) TYPE C,                                 "Invoice No
SUM2(11) TYPE P DECIMALS 2,                            "Sum
END OF IT_SUM.
Internal table to hold Error records
DATA:BEGIN OF IT_ERROR OCCURS 0,
TAX_ID_NO(10) TYPE C,                                  "Tax Id No
INVOICE_NO(12) TYPE C,                                 "Invoice No
MSG(200) TYPE C,                                       "Message
END OF IT_ERROR .
Internal table to hold success records
DATA : BEGIN OF IT_SUCCESS OCCURS 0,
        DOCNUM(10) TYPE C,                           "Document No
        BUKRS(4) TYPE C,                             "Company code
        FISYR(4) TYPE C,                             "Fiscal year
        MSG(100) TYPE C,                             "Message
       END OF IT_SUCCESS.
Internal table to hold invoice no
DATA:BEGIN OF IT_INVNO OCCURS 0,
      XBLNR(16) TYPE C,                              "Ref Doc No
      END OF IT_INVNO.
Internal table to hold Invoice Document no's
DATA:BEGIN OF IT_BKPF OCCURS 0,
      BUKRS LIKE BKPF-BUKRS,
      BELNR LIKE BKPF-BELNR,
      XBLNR LIKE BKPF-XBLNR,
      END OF IT_BKPF.
Internal table to initialise structures
DATA:    BEGIN OF IT_NAMETAB OCCURS 120.
        INCLUDE STRUCTURE DNTAB.
DATA:    END OF IT_NAMETAB.
Internal table to hold sessions data
DATA:BEGIN OF IT_LIST OCCURS 0.
        INCLUDE STRUCTURE ABAPLIST.
DATA:END OF IT_LIST.
Structure to hold input file
DATA:X_INFILE LIKE IT_INFILE.
Structure to hold company code & currency data
DATA:BEGIN OF X_T001,
BUKRS LIKE T001-BUKRS,                                "Company code
WAERS LIKE T001-WAERS,                                "Currency
END OF X_T001.
Global Variables                                                     *
DATA: V_PGM_ID         LIKE SY-REPID,                "Program id
      V_COUNT_INFILE   TYPE I,                       "Counter
      V_TEXT(100)      TYPE C,                       "Text
      V_CHAR(61)       TYPE C,                       "Field name
      V_FILE           LIKE RLGRAP-FILENAME.         "File name
DATA:
      V_ERR            TYPE I,                       "Counter
      V_OBJKEY         LIKE  BAPIACHE09-OBJ_KEY,     "object key
      V_ERR_REC        TYPE I,                       "Error Records
      V_SUC_REC        TYPE I,                       "Success Records
      V_SESS           LIKE APQI-GROUPID.            "Session name
Field symbols
FIELD-SYMBOLS: <F1> .
Constants.                                                           *
DATA:
     C_ITEMNO(6)   TYPE C VALUE '000001',            "Item no
     C_DOCTYPE(2)  TYPE C VALUE 'KU',                "Doc type
     C_BUSACT(4)   TYPE C VALUE 'RMRP',              "Business Account
     C_FADS(7)     TYPE C VALUE 'FADS',              "Legacy system
     C_COMMA(1)    TYPE C VALUE ',' ,                "Comma
     C_NODATA(1)   TYPE C VALUE '/',                 "NODATA
     C_SESS        LIKE APQI-GROUPID VALUE 'FADS2SAP'."Session
Selection Screen
SELECTION-SCREEN: BEGIN OF BLOCK NO1 WITH FRAME TITLE TEXT-001.
*Input file name
PARAMETERS:P_BUKRS  LIKE T001-BUKRS OBLIGATORY,
           P_INFILE LIKE RLGRAP-FILENAME LOWER CASE DEFAULT
                                           'C:\FB60.txt' OBLIGATORY,
*Filename for Error records
            P_ERR LIKE RLGRAP-FILENAME LOWER CASE DEFAULT
  '/int/D01/030/in/REQ853err.txt' OBLIGATORY.
*For selecting either a sequential file or local file.
PARAMETERS:
           R_PSERV RADIOBUTTON GROUP GR1 DEFAULT 'X',
           R_ASERV RADIOBUTTON GROUP GR1.
SELECTION-SCREEN: END OF BLOCK NO1.
INITIALIZATION
INITIALIZATION.
  V_PGM_ID = SY-REPID.
AT SELECTION-SCREEN                                                 *
AT SELECTION-SCREEN.
Validating company code
  SELECT SINGLE BUKRS
         WAERS INTO (X_T001-BUKRS, X_T001-WAERS)
         FROM T001 WHERE BUKRS = P_BUKRS.
  IF SY-SUBRC <> 0.
    MESSAGE E014 WITH 'Invalid Company code'(E01).
  ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_INFILE.
Getting help for presentation server files
  IF R_PSERV = 'X'.
    CALL FUNCTION 'F4_FILENAME'
         EXPORTING
              PROGRAM_NAME  = V_PGM_ID
              DYNPRO_NUMBER = SY-DYNNR
              FIELD_NAME    = ' '
         IMPORTING
              FILE_NAME     = P_INFILE.
  ENDIF.
START-OF-SELECTION                                                  *
START-OF-SELECTION.
If sequential file is selected
  IF R_ASERV = 'X'.
Form to get  data for apllication server
    PERFORM F_GET_INPUT_DATA.
if local file
  ELSE.
If sequential file is selected
    PERFORM F_GET_LOCAL_DATA.
  ENDIF.
Selecting GL, Costcenter, vendor data
  PERFORM F_SELECT_DATA.
Validate the the input file data
  PERFORM F_VALIDATE_DATA.
Populate data to fill structures
  PERFORM F_POPULATE_DATA.
Populate the error data
  PERFORM F_ERROR_DATA.
END-OF-SELECTION
END-OF-SELECTION.
  IF NOT IT_INFILE[] IS INITIAL.
For submitting the program to rfbibloo
    PERFORM F_SUBMIT_RFBIBLOO.
  ENDIF.
WRITE : / 'Number of success records '(003),
           v_suc_rec LEFT-JUSTIFIED.
WRITE : / 'Number of error records '(004),
            v_err_rec LEFT-JUSTIFIED.
  IF NOT IT_ERRORS[] IS INITIAL.
Form to display the error report
    PERFORM F_DISPLAY_REPORT.
  ENDIF.
  IF NOT IT_SUCCESS[] IS INITIAL.
Form to display the success report
    PERFORM F_DISPLAY_SUC_REPORT.
  ENDIF.
*--Standard footer
  PERFORM STD_END_OF_REPORT.
TOP OF PAGE                                                         *
TOP-OF-PAGE.
*---Standard header
  PERFORM STD_TOP_OF_PAGE CHANGING SY-TITLE.
*&      Form  f_get_local_data
      Getting the data from presentation server
FORM F_GET_LOCAL_DATA.
  DATA:LV_FILNAM TYPE STRING.     "File name
  LV_FILNAM = P_INFILE.
  CALL FUNCTION 'GUI_UPLOAD'
       EXPORTING
            FILENAME                = LV_FILNAM
            FILETYPE                = 'ASC'
           has_field_separator     = ' '
       TABLES
            DATA_TAB                = IT_INFILE
       EXCEPTIONS
            FILE_OPEN_ERROR         = 1
            FILE_READ_ERROR         = 2
            NO_BATCH                = 3
            GUI_REFUSE_FILETRANSFER = 4
            INVALID_TYPE            = 5
            NO_AUTHORITY            = 6
            UNKNOWN_ERROR           = 7
            BAD_DATA_FORMAT         = 8
            HEADER_NOT_ALLOWED      = 9
            SEPARATOR_NOT_ALLOWED   = 10
            HEADER_TOO_LONG         = 11
            UNKNOWN_DP_ERROR        = 12
            ACCESS_DENIED           = 13
            DP_OUT_OF_MEMORY        = 14
            DISK_FULL               = 15
            DP_TIMEOUT              = 16
            OTHERS                  = 17.
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  CLEAR V_COUNT_INFILE.
  DESCRIBE TABLE IT_INFILE LINES V_COUNT_INFILE.
Determine if input file has data
  IF V_COUNT_INFILE EQ 0.
    MESSAGE A001(ZFI).
    EXIT.
  ELSE.
    CONCATENATE 'Number of records read from input file  '(002)
                P_INFILE
                ': ' INTO V_TEXT.
    WRITE: / V_TEXT, V_COUNT_INFILE LEFT-JUSTIFIED.
  ENDIF.
ENDFORM.                    " f_get_local_data
*&      Form  F_GET_INPUT_DATA
      Getting the data from apllication server
FORM F_GET_INPUT_DATA.
  DATA: LV_FILNAM LIKE FILENAME-FILEEXTERN."File name
  LV_FILNAM = P_INFILE.
Opening Dataset
  OPEN DATASET LV_FILNAM FOR INPUT IN TEXT MODE.
Read legacy input file into internal table for furthing processing
  DO.
    CLEAR IT_INFILE.
    READ DATASET P_INFILE INTO IT_INFILE.
    IF SY-SUBRC NE 0.
      EXIT.
    ENDIF.
    ADD 1 TO V_COUNT_INFILE.
  ENDDO.
Determine if input file has data
  IF V_COUNT_INFILE EQ 0.
    MESSAGE A001(ZFI).
    EXIT.
  ELSE.
    CONCATENATE 'Number of records read from input file  '(002)
                P_INFILE
                ': ' INTO V_TEXT.
    WRITE: / V_TEXT, V_COUNT_INFILE LEFT-JUSTIFIED.
    EXIT.
  ENDIF.
closing dataset
  CLOSE DATASET LV_FILNAM.
ENDFORM.
*&      Form  f_populate_data
      Populate data
FORM F_POPULATE_DATA.
  CLEAR: X_INFILE,IT_SUCCESS,V_SUC_REC.
  REFRESH IT_SUCCESS.
  SORT IT_INFILE BY TAX_ID_NO INVOICE_NO.
  CONCATENATE '/int/' SY-SYSID '/' SY-MANDT '/in/IR853_FB01.dat'
                                                     INTO V_FILE.
  CONDENSE V_FILE NO-GAPS.
Open the dataset
  OPEN DATASET V_FILE FOR OUTPUT IN TEXT MODE.
  IF SY-SUBRC EQ 0.
    LOOP AT IT_INFILE.
      X_INFILE = IT_INFILE.
      AT FIRST.
To populate BGR00 structure
        PERFORM F_POPULATE_BGR00.
        TRANSFER BGR00 TO V_FILE.
      ENDAT.
      AT NEW INVOICE_NO.
To populate BBKPF structure
        PERFORM F_POPULATE_BBKPF.
        TRANSFER BBKPF TO V_FILE.
To populate BBSEG structure Credit
        PERFORM POPULATE_BBSEG_C.
        TRANSFER BBSEG TO V_FILE.
      ENDAT.
To populate BBKPF structure Debit
      PERFORM POPULATE_BBSEG_D.
      TRANSFER BBSEG TO V_FILE.
      CLEAR:X_INFILE.
    ENDLOOP.
  ENDIF.
ENDFORM.                    " f_populate_data
*&      Form  f_display_report
      Display error report
FORM F_DISPLAY_REPORT.
Open the dataset
  OPEN DATASET P_ERR FOR OUTPUT IN TEXT MODE.
  IF SY-SUBRC EQ 0.
    LOOP AT IT_ERRORS.
Transfer the error records to error file on application server
      TRANSFER IT_ERRORS TO P_ERR.
    ENDLOOP.
  ENDIF.
Closing the dataset
  CLOSE DATASET  P_ERR.
  IF NOT IT_ERRORS[] IS INITIAL.
    FORMAT COLOR 1 INTENSIFIED OFF.
    SKIP 2.
    WRITE:/1(673) 'ERROR REPORT'(H01) CENTERED.
    ULINE /1(673).
    WRITE:/(4)'S.No'(005),
            SY-VLINE,
           (10) 'Tax Id No'(006),
           SY-VLINE,
           (12) 'Invoice No'(007),
           SY-VLINE,
           (8) 'Rec Type'(008),
           SY-VLINE,
           (6) 'Seq No'(009),
           SY-VLINE,
           (8) 'Batch No'(010),
           SY-VLINE,
           (8) 'UserID'(011),
           SY-VLINE,
           (8) 'NU1'(012),
           SY-VLINE,
           (11) 'Inv Amt'(013),
           SY-VLINE,
           (8) 'Inv Date'(014),
           SY-VLINE,
           (10) 'G/L Org ID'(015),
           SY-VLINE,
           (4) 'NU4'(012),
           SY-VLINE,
           (4) 'NU5'(012),
           SY-VLINE,
           (4) 'NU6'(012),
           SY-VLINE,
           (4) 'NU7'(012),
           SY-VLINE,
           (11) 'NU8'(012),
           SY-VLINE,
           (4) 'NU9'(012),
           SY-VLINE,
           (10) 'PO No'(016),
           SY-VLINE,
           (30) 'Inv Desc'(017),
           SY-VLINE,
           (10) 'Voucher No'(018),
           SY-VLINE,
           (10) 'Inv LinNo'(019),
           SY-VLINE,
           (11) 'Inv Lin Amt'(020),
           SY-VLINE,
           (9) 'Led ID-1'(021),
           SY-VLINE,
           (9) 'Led ID-2'(022),
           SY-VLINE,
           (15) 'Pri Sub Acc-1'(023),
           SY-VLINE,
           (15) 'Pri Sub Acc-2'(024),
           SY-VLINE,
           (15) 'Dept Win Lgr'(025),
           SY-VLINE,
           (5) 'NU2'(012),
           SY-VLINE,
           (6) 'NU3'(012),
           SY-VLINE,
           (11) 'Dist Amt'(026),
           SY-VLINE,
           (8) 'Inv Type'(027),
            SY-VLINE,
           (12) 'PO Line No'(028),
           SY-VLINE,
           (15) 'Inv Line Amt'(029),
           SY-VLINE,
           (5) 'NU10'(012),
           SY-VLINE,
           (13) 'NU11'(012),
           SY-VLINE,
           (5) 'NU12'(012),
           SY-VLINE,
           (6) 'NU13'(012),
           SY-VLINE,
           (5) 'NU14'(012),
           SY-VLINE,
           (5) 'NU15'(012),
           SY-VLINE,
           (200) 'Message'(030),
           SY-VLINE.
    FORMAT COLOR 6 INTENSIFIED OFF.
    LOOP AT IT_ERRORS.
      WRITE:/(4) SY-TABIX,
            SY-VLINE,
           (10) IT_ERRORS-TAX_ID_NO,
           SY-VLINE,
           (12) IT_ERRORS-INVOICE_NO,
           SY-VLINE,
           (8) IT_ERRORS-RECORD_TYPE,
           SY-VLINE,
           (6) IT_ERRORS-SEQ_NO,
           SY-VLINE,
           (8) IT_ERRORS-BATCH_NO,
           SY-VLINE,
           (8) IT_ERRORS-USERID,
           SY-VLINE,
           (8) IT_ERRORS-NU1,
           SY-VLINE,
           (11) IT_ERRORS-INV_HEADER_AMT,
           SY-VLINE,
           (8) IT_ERRORS-INVOICE_DATE,
           SY-VLINE,
           (10) IT_ERRORS-GL_ORG_ID,
           SY-VLINE,
           (4) IT_ERRORS-NU4,
           SY-VLINE,
           (4) IT_ERRORS-NU5,
           SY-VLINE,
           (4) IT_ERRORS-NU6,
           SY-VLINE,
           (4) IT_ERRORS-NU7,
           SY-VLINE,
           (11) IT_ERRORS-NU8,
           SY-VLINE,
           (4) IT_ERRORS-NU9,
           SY-VLINE,
           (10) IT_ERRORS-PONUMBER,
           SY-VLINE,
           (30) IT_ERRORS-INV_DESC,
           SY-VLINE,
           (10) IT_ERRORS-VOUCHER_NO,
           SY-VLINE,
           (10) IT_ERRORS-INV_LINE_NO,
           SY-VLINE,
           (11) IT_ERRORS-INV_LINE_AMT,
           SY-VLINE,
           (9) IT_ERRORS-LEDGER_ID1,
           SY-VLINE,
           (9) IT_ERRORS-LEDGER_ID2,
           SY-VLINE,
           (15) IT_ERRORS-PRI_SUBACCT1,
           SY-VLINE,
           (15) IT_ERRORS-PRI_SUBACCT2,
           SY-VLINE,
           (15) IT_ERRORS-DEPT_WIN_LDGR,
           SY-VLINE,
           (5) IT_ERRORS-NU2,
           SY-VLINE,
           (6) IT_ERRORS-NU3,
           SY-VLINE,
           (11) IT_ERRORS-DIST_AMT,
           SY-VLINE,
           (8) IT_ERRORS-INV_TYPE,
           SY-VLINE,
           (12) IT_ERRORS-PO_LINE_NO,
           SY-VLINE,
           (15) IT_ERRORS-INV_LINE_AMT_D,
           SY-VLINE,
           (5) IT_ERRORS-NU10,
           SY-VLINE,
           (13) IT_ERRORS-NU11,
           SY-VLINE,
           (5) IT_ERRORS-NU12,
           SY-VLINE,
           (6) IT_ERRORS-NU13,
           SY-VLINE,
           (5) IT_ERRORS-NU14,
           SY-VLINE,
           (5) IT_ERRORS-NU15,
           SY-VLINE,
           (200) IT_ERRORS-MSG,
           SY-VLINE.
    ENDLOOP.
    ULINE /1(673).
  ENDIF.
ENDFORM.                    " f_display_report
*&      Form  f_select_data
Selection of GL, Costcenter, vendor data
FORM F_SELECT_DATA.
  DATA:L_DEPT(4) TYPE N. "Legacy department
  CLEAR:IT_GL, IT_COSTCTR, IT_LFA1, IT_SUBACCT, IT_TAXID , IT_SUM.
  REFRESH:IT_GL, IT_COSTCTR, IT_LFA1, IT_SUBACCT, IT_TAXID,IT_SUM.
  SORT IT_INFILE BY TAX_ID_NO INVOICE_NO.
*Looping at input file
  LOOP AT IT_INFILE.
    X_INFILE = IT_INFILE.
*Summing the invoice line items amount and moving the sum to it_sum
    IT_SUM-TAX_ID_NO = IT_INFILE-TAX_ID_NO.
    IT_SUM-INVOICE_NO  = IT_INFILE-INVOICE_NO.
    IT_SUM-SUM2 = IT_INFILE-INV_LINE_AMT.
    COLLECT IT_SUM.
    CLEAR IT_SUM.
*Storing Primary Sub Account data
    IT_SUBACCT-PRYACT1 = IT_INFILE-PRI_SUBACCT1.
    IT_SUBACCT-PRYACT2 = IT_INFILE-PRI_SUBACCT2.
    APPEND IT_SUBACCT.
    CLEAR IT_SUBACCT.
*Storing Ledger ID data
    CONCATENATE IT_INFILE-LEDGER_ID1 IT_INFILE-LEDGER_ID2 INTO
    IT_LEDGER-LGR_ID.
    L_DEPT = IT_INFILE-DEPT_WIN_LDGR.
    IT_LEDGER-DEPT = L_DEPT.
    APPEND IT_LEDGER.
    CLEAR IT_LEDGER.
*Storing Tax ID data
    IT_TAXID-TAXID1 = IT_INFILE-TAX_ID_NO.
    IT_TAXID-TAXID2 = IT_INFILE-TAX_ID_NO.
    APPEND IT_TAXID.
    CLEAR IT_TAXID.
    CONDENSE IT_INFILE-INVOICE_NO.
    IT_INVNO-XBLNR = IT_INFILE-INVOICE_NO.
    APPEND IT_INVNO.
    CLEAR IT_INVNO.
  ENDLOOP.
  SORT IT_SUBACCT BY PRYACT1  PRYACT2.
  SORT IT_LEDGER BY LGR_ID DEPT.
  SORT IT_TAXID BY TAXID1 TAXID2.
  SORT IT_SUM  BY TAX_ID_NO INVOICE_NO.
  SORT IT_INVNO BY XBLNR.
  DELETE ADJACENT DUPLICATES FROM IT_SUBACCT COMPARING PRYACT1  PRYACT2.
  DELETE ADJACENT DUPLICATES FROM IT_LEDGER COMPARING LGR_ID DEPT.
  DELETE ADJACENT DUPLICATES FROM IT_TAXID COMPARING TAXID1 TAXID2.
  IF NOT IT_INVNO[] IS INITIAL.
    SELECT BUKRS
           BELNR
           XBLNR
           INTO TABLE IT_BKPF
           FROM BKPF
           FOR ALL ENTRIES IN IT_INVNO
           WHERE BUKRS = P_BUKRS AND
                 GJAHR = SY-DATUM+0(4) AND
                 BLART = C_DOCTYPE AND
                 XBLNR = IT_INVNO-XBLNR.
  ENDIF.
  IF NOT IT_SUBACCT[] IS INITIAL.
*Selecting G/L Account from General Ledger Z Table
    SELECT SAP_GL_ACCOUNT
    LGCY_SYSTEM
    LGCY_PRIME_ACCT
    LGCY_SUB_ACCT FROM ZFGLT_GL_PRI_SUB
    INTO TABLE IT_GL
    FOR ALL ENTRIES IN IT_SUBACCT
    WHERE LGCY_SYSTEM = C_FADS AND
           LGCY_PRIME_ACCT = IT_SUBACCT-PRYACT1 AND
           LGCY_SUB_ACCT = IT_SUBACCT-PRYACT2.
    IF SY-SUBRC  = 0.
      SORT IT_GL BY SAP_GL_ACCOUNT
      LGCY_SYSTEM
      LGCY_PRIME_ACCT
      LGCY_SUB_ACCT.
    ENDIF.
    IF NOT IT_LEDGER[] IS INITIAL.
*Selecting cost center from Cost Center Z Table
      SELECT COST_OBJECT
      LGCY_LDGR
      LGCY_DEPT FROM ZFCFT_CTR_DPT_LG
      INTO TABLE IT_COSTCTR
      FOR ALL ENTRIES IN IT_LEDGER
      WHERE LGCY_LDGR = IT_LEDGER-LGR_ID AND
            LGCY_DEPT = IT_LEDGER-DEPT.
      IF SY-SUBRC = 0.
        SORT IT_COSTCTR BY COST_OBJECT
        LGCY_LDGR
        LGCY_DEPT.
      ENDIF.
    ENDIF.
    IF NOT IT_TAXID[] IS INITIAL.
*Selecting vendor no from vendor master data
      SELECT A~LIFNR
             B~BUKRS
             A~STCD1
             A~STCD2
             FROM LFA1 AS A JOIN LFB1 AS B
             ON ALIFNR = BLIFNR
             INTO TABLE IT_LFA1
             FOR ALL ENTRIES IN IT_TAXID
             WHERE BUKRS = P_BUKRS AND
            (  STCD1 = IT_TAXID-TAXID1 OR
              STCD2 = IT_TAXID-TAXID2 ).
    ENDIF.
  ENDIF.
ENDFORM.                    " f_select_data
*&      Form  f_validate_data
         Validation of input file data
FORM F_VALIDATE_DATA.
  DATA:L_ERRFLAG TYPE C,              "Error flag
       L_DEPT(4) TYPE N,              "Department
       L_LGR_ID(4) TYPE C,            "Ledger ID
       LV_NO_OF_VENDORS TYPE I,       "No of vendors
       L_SUM(11) TYPE P DECIMALS 2,   "Sum
       LV_MSG1(30) TYPE C,            "Message
       LV_MSG2(25) TYPE C,            "Message
       LV_MSG3(6) TYPE C,             "Message
       LV_MSG4(31) TYPE C,            "Message
       LV_MSG5(53) TYPE C,            "Message
       LV_MSG6(30) TYPE C,            "Message
       LV_MSG7(50) TYPE C.            "Message
  LOOP AT IT_INFILE.
    CLEAR:LV_MSG1,LV_MSG2, LV_MSG3,LV_MSG4,LV_MSG5, LV_MSG6, LV_MSG7.
    CLEAR L_ERRFLAG.
    SORT IT_SUM BY TAX_ID_NO
                   INVOICE_NO.
    CLEAR IT_SUBACCT.
Validating Primary Sub Acct1 and Acct2.
    READ TABLE IT_GL WITH KEY LGCY_SYSTEM = C_FADS
               LGCY_PRIME_ACCT = IT_INFILE-PRI_SUBACCT1
               LGCY_SUB_ACCT  = IT_INFILE-PRI_SUBACCT2 .
    IF SY-SUBRC <> 0.
      LV_MSG1 = 'Primary Sub Acct1 and Acct2'(035).
      L_ERRFLAG = 'X'.
    ENDIF.
    MOVE IT_INFILE-DEPT_WIN_LDGR TO L_DEPT.
    MOVE L_DEPT TO IT_INFILE-DEPT_WIN_LDGR.
    CONCATENATE IT_INFILE-LEDGER_ID1 IT_INFILE-LEDGER_ID2 INTO
L_LGR_ID.
    CLEAR: IT_COSTCTR.
Validating Ledger id & department
    READ TABLE IT_COSTCTR WITH KEY LGCY_LDGR = L_LGR_ID
                             LGCY_DEPT = IT_INFILE-DEPT_WIN_LDGR.
    IF SY-SUBRC <> 0.
      LV_MSG2 = 'Ledger id & department'(036).
      L_ERRFLAG = 'X'.
    ENDIF.
Validating Tax ID
    CLEAR:IT_LFA1.
    READ TABLE IT_LFA1 WITH KEY STCD2 = IT_INFILE-TAX_ID_NO..
    IF SY-SUBRC <> 0.
      READ TABLE IT_LFA1 WITH KEY STCD1 = IT_INFILE-TAX_ID_NO..
      IF SY-SUBRC <> 0.
        LV_MSG3 = 'Tax ID'(041).
        L_ERRFLAG = 'X'.
      ENDIF.
    ENDIF.
Checking for no of vendors selected based on tax id. If no of vendors
selected are more than 1 or 0 then error out the record
    LV_NO_OF_VENDORS = 0.
    LOOP AT IT_LFA1 WHERE STCD1 = IT_INFILE-TAX_ID_NO OR
                          STCD2 = IT_INFILE-TAX_ID_NO.
      LV_NO_OF_VENDORS = LV_NO_OF_VENDORS + 1.
    ENDLOOP.
    IF LV_NO_OF_VENDORS = 0.
      LV_MSG6 = 'No vendor found for TAXID'(037).
      L_ERRFLAG = 'X'.
    ELSEIF LV_NO_OF_VENDORS > 1.
      LV_MSG4 = 'More than one vendor for Tax id'(038).
      L_ERRFLAG = 'X'.
    ENDIF.
Checking whether KU Document already exists for this Invoice No
    CLEAR IT_INVNO.
    READ TABLE IT_BKPF WITH KEY XBLNR = IT_INFILE-INVOICE_NO.
    IF SY-SUBRC = 0.
      LV_MSG7 = 'KU Document already exists for this Invoice No '(042).
      L_ERRFLAG = 'X'.
    ENDIF.
Checking whether the invoice header amt is equal to the line items amt
    CLEAR IT_SUM.
    READ TABLE IT_SUM WITH KEY TAX_ID_NO = IT_INFILE-TAX_ID_NO
                   INVOICE_NO = IT_INFILE-INVOICE_NO BINARY SEARCH.
    CLEAR L_SUM.
    L_SUM = IT_INFILE-INV_HEADER_AMT.
    IF L_SUM <> IT_SUM-SUM2.
  LV_MSG5 = 'Header amt is not equal to the sum of all line items'(039).
      L_ERRFLAG = 'X'.
    ENDIF.
Moving error records to error internal table
    IF L_ERRFLAG = 'X'.
      MOVE IT_INFILE TO IT_ERRORS.
    CONCATENATE 'Invalid:'(040) LV_MSG1 LV_MSG2 LV_MSG3 LV_MSG4 LV_MSG5
             LV_MSG6 LV_MSG7 INTO IT_ERRORS-MSG SEPARATED BY SPACE.
      APPEND IT_ERRORS.
      CLEAR : IT_ERRORS.
Deleting all the errors records from the processing internal table
and moving them to error table
      V_ERR = V_ERR + 1.
      IT_INFILE-ERROR = 'X'.
      MODIFY IT_INFILE TRANSPORTING ERROR.
      CLEAR IT_INFILE.
    ENDIF.
  ENDLOOP.
  DELETE IT_INFILE WHERE ERROR = 'X'.
Deleting all the line items from the processing internal table where
atleast one line item is error one
  SORT IT_ERRORS BY TAX_ID_NO
                    INVOICE_NO.
  CLEAR V_ERR_REC.
  LOOP AT IT_ERRORS.
    DELETE IT_INFILE WHERE TAX_ID_NO = IT_ERRORS-TAX_ID_NO AND
                           INVOICE_NO = IT_ERRORS-INVOICE_NO.
    AT NEW INVOICE_NO.
      V_ERR_REC = V_ERR_REC + 1.
    ENDAT.
  ENDLOOP.
ENDFORM.                    " f_validate_data
*&      Form  f_error_data
      Processing error data
FORM F_ERROR_DATA.
  DELETE IT_ERROR WHERE MSG = 'Error in document: BKPFF $ D01030'(E02).
  SORT IT_ERROR BY TAX_ID_NO INVOICE_NO.
  LOOP AT IT_INFILE.
    X_INFILE = IT_INFILE.
    READ TABLE IT_ERROR WITH KEY TAX_ID_NO = IT_INFILE-TAX_ID_NO
                      INVOICE_NO = IT_INFILE-INVOICE_NO BINARY SEARCH.
    IF SY-SUBRC = 0.
      AT NEW INVOICE_NO.
        V_ERR_REC = V_ERR_REC + 1.
      ENDAT.
      MOVE X_INFILE TO IT_ERRORS.
      IT_ERRORS-MSG = IT_ERROR-MSG.
      APPEND IT_ERRORS.
      CLEAR IT_ERRORS.
    ENDIF.
  ENDLOOP.
ENDFORM.                    " f_error_data
*&      Form  f_display_suc_report
      Display success report
FORM F_DISPLAY_SUC_REPORT.
  FORMAT COLOR OFF.
  FORMAT COLOR 1 INTENSIFIED OFF.
  SKIP 2.
  WRITE:/1(150) 'SUCCESS REPORT'(S01) CENTERED.
  ULINE /1(150).
  WRITE:/1 SY-VLINE,
         2 'Doc No'(031),
        13 SY-VLINE,
        14 'Company code'(032),
        26 SY-VLINE,
        27 'Fiscal Year'(033),
        40 SY-VLINE,
        41 'Message'(034),
       150 SY-VLINE.
  FORMAT COLOR OFF.
  FORMAT COLOR 5 INTENSIFIED OFF.
  LOOP AT IT_SUCCESS.
    WRITE:/1 SY-VLINE,
             2 IT_SUCCESS-DOCNUM,
            13 SY-VLINE,
            14 IT_SUCCESS-BUKRS,
            26 SY-VLINE,
            27 IT_SUCCESS-FISYR,
            40 SY-VLINE,
            41 IT_SUCCESS-MSG,
           150 SY-VLINE.
  ENDLOOP.
  ULINE /1(150).
ENDFORM.                    " f_display_suc_report
*&      Form  F_populate_bgr00
To populate BGR00 structure
FORM F_POPULATE_BGR00.
  PERFORM F_INIT_STRUCTURES USING 'BGR00' C_NODATA.
  CLEAR V_SESS.
  CONCATENATE C_SESS SY-DATUM+4(4) INTO V_SESS SEPARATED BY '-'.
  BGR00-STYPE  = '0'.
  BGR00-GROUP  = V_SESS.
  BGR00-MANDT  = SY-MANDT.
  BGR00-USNAM  = SY-UNAME.
  BGR00-START  = SPACE.
  BGR00-XKEEP  = 'X'.
ENDFORM.                    " F_populate_bgr00
*&      Form  F_init_structures
   Form to initialise structures
FORM F_INIT_STRUCTURES USING TABNAME  LIKE DNTAB-TABNAME
                           I_NODATA LIKE C_NODATA.
  REFRESH IT_NAMETAB.
  CLEAR IT_NAMETAB.
  CALL FUNCTION 'NAMETAB_GET'
       EXPORTING
            LANGU          = SY-LANGU
            TABNAME        = TABNAME
       TABLES
            NAMETAB        = IT_NAMETAB
       EXCEPTIONS
            NO_TEXTS_FOUND = 1.
  IF SY-SUBRC = 0.
    LOOP AT IT_NAMETAB.
      CLEAR V_CHAR.
   CONCATENATE  IT_NAMETAB-TABNAME '-' IT_NAMETAB-FIELDNAME INTO V_CHAR.
      ASSIGN (V_CHAR) TO <F1>.
      <F1> = I_NODATA.
    ENDLOOP.
  ENDIF.
ENDFORM.                    " INIT_STRUCTURES
*&      Form  f_populate_bbkpf
To populate BBKPF structure
FORM F_POPULATE_BBKPF.
  DATA:LV_DAT LIKE BKPF-BUDAT.
  PERFORM F_INIT_STRUCTURES USING 'BBKPF' C_NODATA.
To post Header record.
  BBKPF-STYPE = '1'.
  BBKPF-TCODE = 'FB01'.
  CLEAR LV_DAT.
  LV_DAT = SY-DATUM.
  WRITE LV_DAT TO BBKPF-BUDAT.
  CLEAR LV_DAT.
  LV_DAT = X_INFILE-INVOICE_DATE.
  WRITE LV_DAT TO BBKPF-BLDAT.
  BBKPF-BLART = C_DOCTYPE.
  BBKPF-BUKRS = P_BUKRS..
  BBKPF-WAERS = X_T001-WAERS.
  BBKPF-XBLNR = X_INFILE-INVOICE_NO.
ENDFORM.                    " f_populate_bbkpf
*&      Form  populate_bbseg_c
To populate BBSEG structure Credit
FORM POPULATE_BBSEG_C.
  PERFORM F_INIT_STRUCTURES USING 'BBSEG' C_NODATA.
  BBSEG-STYPE = '2'.
  BBSEG-TBNAM = 'BBSEG'.
  BBSEG-NEWBS = '31'.
  READ TABLE IT_LFA1 WITH KEY STCD2 = X_INFILE-TAX_ID_NO .
  IF SY-SUBRC  = 0.
    BBSEG-NEWKO = IT_LFA1-LIFNR.
  ELSE.
    READ TABLE IT_LFA1 WITH KEY STCD1 = X_INFILE-TAX_ID_NO .
    IF SY-SUBRC  = 0.
      BBSEG-NEWKO = IT_LFA1-LIFNR.
    ENDIF.
  ENDIF.
  BBSEG-WRBTR = X_INFILE-INV_HEADER_AMT.
  BBSEG-SGTXT = X_INFILE-INV_DESC.
ENDFORM.                    " populate_bbseg_c
*&      Form  POPULATE_BBSEG_D
To populate BBSEG structure Debit
FORM POPULATE_BBSEG_D.
  DATA:L_LGR_ID(4) TYPE C. "ledger id
  CLEAR L_LGR_ID.
  PERFORM F_INIT_STRUCTURES USING 'BBSEG' C_NODATA.
  BBSEG-STYPE = '2'.
  BBSEG-TBNAM = 'BBSEG'.
  BBSEG-NEWBS = '40'.
*Fetching G/L account
  READ TABLE IT_GL WITH KEY LGCY_SYSTEM = C_FADS
                 LGCY_PRIME_ACCT = X_INFILE-PRI_SUBACCT1
                 LGCY_SUB_ACCT  = X_INFILE-PRI_SUBACCT2.
  IF SY-SUBRC = 0.
    BBSEG-NEWKO  = IT_GL-SAP_GL_ACCOUNT.
  ENDIF.
  BBSEG-WRBTR = X_INFILE-INV_LINE_AMT.
  CONCATENATE X_INFILE-LEDGER_ID1 X_INFILE-LEDGER_ID2 INTO
L_LGR_ID.
*Fetching  costcenter
  READ TABLE IT_COSTCTR WITH KEY LGCY_LDGR = L_LGR_ID
                           LGCY_DEPT = X_INFILE-DEPT_WIN_LDGR.
  IF SY-SUBRC = 0.
    BBSEG-KOSTL = IT_COSTCTR-COST_OBJECT.
  ENDIF.
  BBSEG-SGTXT = X_INFILE-INV_DESC.
ENDFORM.                    " POPULATE_BBSEG_D
*&      Form  f_submit_rfbibloo
     Submit the program to rfbibloo
FORM F_SUBMIT_RFBIBLOO.
Submitting the file for RFBIBL00
  SUBMIT RFBIBL00 WITH DS_NAME = V_FILE
                  WITH CALLMODE = 'B'
                  WITH MAX_COMM = '9999'
                  WITH XINF = 'X'
                  AND RETURN.
Process the session if created successfully
  IF SY-SUBRC = 0.
    SUBMIT RSBDCSUB  WITH MAPPE    = V_SESS
                     WITH Z_VERARB = 'X'
                     WITH FEHLER = ''
                     EXPORTING LIST TO MEMORY
                     AND RETURN.
    IF SY-SUBRC  = 0.
Displaying the sessions data
      PERFORM F_SESSION_LIST.
    ENDIF.
  ENDIF.
ENDFORM.                    " f_submit_rfbibloo
*&      Form  f_session_list
      Displaying the sessions data
FORM F_SESSION_LIST.
  DATA:LV_UCOMM LIKE SY-UCOMM. "usercommand
  CALL FUNCTION 'LIST_FROM_MEMORY'
       TABLES
            LISTOBJECT = IT_LIST
       EXCEPTIONS
            NOT_FOUND  = 1
            OTHERS     = 2.
  IF NOT IT_LIST[] IS INITIAL.
    CALL FUNCTION 'DISPLAY_LIST'
EXPORTING
  FULLSCREEN                  = 'X'
  CALLER_HANDLES_EVENTS       =
     IMPORTING
       USER_COMMAND                =  LV_UCOMM
      TABLES
        LISTOBJECT                  = IT_LIST
   EXCEPTIONS
     EMPTY_LIST                  = 1
     OTHERS                      = 2
  ENDIF.
ENDFORM.                    " f_session_list

Similar Messages

  • BAPI for vendor credit memo posting by FB65

    Hi guys,
    I need a BAPI to post vendor credit note by FB65.
    I am trying BAPI_ACC_DOCUMENT_POST, but I cannot find the fields to fill with the information we input at FB65 Payment tab, such as: Inv. Ref (document, year and item ).
    Could anybody help me?
    Cheers,
    Karla.

    HI ,
    Please Find below the relevant code to Fill the Fields while calling the BAPI for FB65
    step1.
    First of all fill the wa_bapiheader.
    *header data
        wa_bapiheader-username = sy-uname.
        wa_bapiheader-comp_code = wa_final-bukrs.
        wa_bapiheader-doc_date = sy-datum.
        wa_bapiheader-pstng_date = sy-datum.
        wa_bapiheader-doc_type = c_blart.
        wa_bapiheader-ref_doc_no = 'GROWPAY'.   "Can be the refrence text
        w_waers = wa_final-waers.
    Step2.
    Fill this internal table. i_currencyamount  and i_accountgl.
    i_final will be the Internal table conating all the Relevant data for Posting the Document.
    Loop at  i_final into wa_final.
    ADD 1 TO w_acc_lno.
        wa_accountgl-itemno_acc = w_acc_lno.        
        wa_accountgl-gl_account = wa_final-saknr.    "G/L Account
        wa_accountgl-plant = wa_final-werks.             " Plant
        wa_accountgl-costcenter = wa_final-kostl.       " Cost Center
        wa_accountgl-cond_type = wa_final-knumv.    "From EKKO for the Purchase Order
        wa_accountgl-po_number = wa_final-ebeln.    " Purchase Order no
        wa_accountgl-po_item = wa_final-ebelp.         " Line item in PO
        APPEND wa_accountgl TO i_accountgl.
        CLEAR : wa_accountgl.
        wa_currencyamount-itemno_acc = w_acc_lno.
        wa_currencyamount-currency = wa_final-waers.
        wa_currencyamount-amt_doccur = wa_final-kbetr.
        w_sum = w_sum + wa_final-kbetr.
        APPEND wa_currencyamount TO i_currencyamount.     " G/L line item
        CLEAR : wa_currencyamount.
    *item  data
          wa_accountpayable-itemno_acc = 1.
          wa_accountpayable-vendor_no = wa_final-lifnr.
          APPEND wa_accountpayable TO i_accountpayable.
    *Amount for the vendor line item.
          CLEAR : wa_currencyamount.
          wa_currencyamount-itemno_acc = 1.
          wa_currencyamount-currency = w_waers.
          wa_currencyamount-amt_doccur = 0 - w_sum.
          INSERT  wa_currencyamount INTO i_currencyamount INDEX 1.
    Step 3.
    CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
              EXPORTING
                documentheader = wa_bapiheader
              TABLES
                accountgl           = i_accountgl
                currencyamount = i_currencyamount
                accountpayable = i_accountpayable
                return                 = i_result_out.
    i_result_out will conatin the messages returned by the BAPI.
        based on i_resuklt_out that is if the posting is Successful....call commit
          CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
                     Wait = X.
    Endloop.
    I hope the above code may solve your problem....Thanks
    Regards ,
    Sonu Krishna.
    Edited by: Sonu Krishna PV on Aug 6, 2009 11:03 AM

  • BAPI for Open production orders

    Hi All,
    Any BAPI for open production orders?.... Using BAPI i want to upload open production orders informatiomations.... Please help
    Thanks & Regards
    Santhosh

    Hi,
       Please check the following BAPI,
    Goto BAPI tcode, select hierarchical tab
      Production orders,ProductionOrder ,ProdOrdConfirmation , RCVPRORDCF and check the BAPIs

  • Bapi for open PO

    Hi!
    Can anyone let me know where to find the bapi for open po and how to use it in my report program.
    Thanks in advance.
    Note: Mr Anji Reddy vangala has answered me for which iam very much thankful to him, but i need to know about the concerned bapi.
    Regards,
    Parwez.

    Hi,
    Refer the sample code below which creats PO using BAPI_PO_CREATE1.
    Hope this helps your querry.
    *& Report  YDM_PO_CREATE                                               *
    REPORT  ydm_po_create.
    *-- Input File Declaration
    TYPES: BEGIN OF ty_input_file,
           column1 TYPE char50,
           column2 TYPE char50,
           column3 TYPE char50,
           column4 TYPE char50,
           column5 TYPE char50,
           column6 TYPE char50,
           column7 TYPE char50,
           column8 TYPE char50,
           column9 TYPE char50,
           column10 TYPE char50,
           column11 TYPE char50,
           column12 TYPE char50,
           column13 TYPE char50,
           column14 TYPE char50,
           column15 TYPE char50,
           column16 TYPE char50,
           column17 TYPE char50,
           column18 TYPE char50,
    END OF ty_input_file.
    DATA: i_input_file  TYPE STANDARD TABLE OF ty_input_file,
          wa_input_file TYPE ty_input_file.
    CONSTANTS: c_path     TYPE char20 VALUE 'C:\',
               c_mask     TYPE char9  VALUE ',*.*,*.*.',
               c_mode     TYPE char1  VALUE 'O',
               c_filetype TYPE char10 VALUE 'ASC',
               c_x        TYPE char01 VALUE 'X'.
    PARAMETERS : p_fname   LIKE rlgrap-filename.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname.
    *-- Browse Presentation Server
      PERFORM f4_presentation_file.
    START-OF-SELECTION..
    *-- Read presentation server file
      PERFORM f1003_upload_file.
      IF NOT i_input_file[] IS INITIAL.
        PERFORM split_data.
      ENDIF.
    *&                  Form  f4_presentation_file
    *&                F4 Help for presentation server
    FORM f4_presentation_file .
      CALL FUNCTION 'WS_FILENAME_GET'
        EXPORTING
          def_path         = c_path
          mask             = c_mask
          mode             = c_mode
          title            = text-001
        IMPORTING
          filename         = p_fname
        EXCEPTIONS
          inv_winsys       = 1
          no_batch         = 2
          selection_cancel = 3
          selection_error  = 4
          OTHERS           = 5.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " f4_presentation_file
    *&                      Form  f1003_upload_file
    *&                         Upload File
    FORM f1003_upload_file .
      DATA: lcl_filename TYPE string.
      lcl_filename = p_fname.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                = lcl_filename
          filetype                = c_filetype
          has_field_separator     = c_x
        TABLES
          data_tab                = i_input_file
        EXCEPTIONS
          file_open_error         = 1
          file_read_error         = 2
          no_batch                = 3
          gui_refuse_filetransfer = 4
          invalid_type            = 5
          no_authority            = 6
          unknown_error           = 7
          bad_data_format         = 8
          header_not_allowed      = 9
          separator_not_allowed   = 10
          header_too_long         = 11
          unknown_dp_error        = 12
          access_denied           = 13
          dp_out_of_memory        = 14
          disk_full               = 15
          dp_timeout              = 16
          OTHERS                  = 17.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        EXIT.
      ENDIF.
    ENDFORM.                    " f1003_upload_file
    *&      Form  split_data
          Collect data for creating Purchase Order
    FORM split_data .
      DATA: i_poitem        TYPE STANDARD TABLE OF bapimepoitem,
            i_poitemx       TYPE STANDARD TABLE OF bapimepoitemx,
            i_poitem_sch    TYPE STANDARD TABLE OF bapimeposchedule,
            i_poitem_schx   TYPE STANDARD TABLE OF bapimeposchedulx,
            i_acct_***      TYPE STANDARD TABLE OF bapimepoaccount,
            i_acct_assx     TYPE STANDARD TABLE OF bapimepoaccountx,
            i_services      TYPE STANDARD TABLE OF bapiesllc ,
            i_srvacc        TYPE STANDARD TABLE OF bapiesklc,
            i_return        TYPE STANDARD TABLE OF bapiret2,
            wa_header       TYPE bapimepoheader,
            wa_headerx      TYPE bapimepoheaderx,
            wa_poitem       TYPE bapimepoitem,
            wa_poitemx      TYPE bapimepoitemx,
            wa_poitem_sch   TYPE bapimeposchedule,
            wa_poitem_schx  TYPE bapimeposchedulx,
            wa_acct_***     TYPE bapimepoaccount,
            wa_acct_assx    TYPE bapimepoaccountx,
            wa_services     TYPE bapiesllc,
            wa_srvacc       TYPE bapiesklc,
            wa_return       TYPE bapiret2,
            ws_po           TYPE bapimepoheader-po_number.
      break gbpra8.
      wa_services-pckg_no = 10.
      wa_services-line_no = 1.
      wa_services-outl_no = '0'.
      wa_services-outl_ind = c_x.
      wa_services-subpckg_no = 20.
      APPEND wa_services TO i_services.
      wa_srvacc-pckg_no = 10.
      wa_srvacc-line_no = 1.
      wa_srvacc-serno_line = 01.
      wa_srvacc-serial_no = 01.
      wa_srvacc-percentage = 100.
      APPEND wa_srvacc TO i_srvacc.
      LOOP AT i_input_file INTO wa_input_file.
        IF wa_input_file-column2 EQ 'HD'.
          wa_header-doc_type = wa_input_file-column3.
          wa_header-creat_date = sy-datum.
          wa_header-created_by = sy-uname.
          wa_header-vendor = wa_input_file-column4.
          PERFORM conversion_output USING wa_header-vendor
                                    CHANGING wa_header-vendor.
          wa_header-comp_code = 'DE03'.
          wa_header-purch_org = 'DE03'.
          wa_header-pur_group = 'DE1'.
          wa_header-vper_start = wa_input_file-column9.
          wa_header-vper_end = wa_input_file-column10.
          wa_headerx-comp_code = c_x.
          wa_headerx-doc_type = c_x.
          wa_headerx-creat_date = c_x.
          wa_headerx-created_by = c_x.
          wa_headerx-vendor = c_x.
          wa_headerx-purch_org = c_x.
          wa_headerx-pur_group = c_x.
          wa_headerx-vper_start = c_x.
          wa_headerx-vper_end = c_x.
        ENDIF.
        IF wa_input_file-column2 EQ 'IT'.
          wa_poitem-po_item = wa_input_file-column3.
          wa_poitem-short_text = wa_input_file-column6.
          wa_poitem-plant = wa_input_file-column8.
          wa_poitem-quantity = '1'.
          wa_poitem-tax_code = 'V0'.
          wa_poitem-item_cat = 'D'.
          wa_poitem-acctasscat = 'K'.
          wa_poitem-matl_group = wa_input_file-column7.
          wa_poitem-pckg_no = '10'.
          APPEND wa_poitem TO i_poitem .
          wa_poitemx-po_item = wa_input_file-column3.
          wa_poitemx-po_itemx = c_x.
          wa_poitemx-short_text = c_x.
          wa_poitemx-plant = c_x.
          wa_poitemx-quantity = c_x.
          wa_poitemx-tax_code = c_x.
          wa_poitemx-item_cat = c_x.
          wa_poitemx-acctasscat = c_x.
          wa_poitemx-matl_group = c_x.
          wa_poitemx-pckg_no = c_x.
          APPEND wa_poitemx TO i_poitemx.
          wa_poitem_sch-po_item = wa_input_file-column3.
          wa_poitem_sch-delivery_date = sy-datum.
          APPEND wa_poitem_sch TO i_poitem_sch.
          wa_poitem_schx-po_item = wa_input_file-column3.
          wa_poitem_schx-po_itemx = c_x.
          wa_poitem_schx-delivery_date = c_x.
          APPEND wa_poitem_schx TO i_poitem_schx.
          wa_acct_***-po_item = 10.
          wa_acct_***-serial_no = 01.
          wa_acct_***-gl_account = '0006360100'.
          wa_acct_***-co_area  = '1000'.
          wa_acct_***-costcenter = 'KC010000'.
          APPEND wa_acct_*** TO i_acct_***.
          wa_acct_***-po_item = 10.
          wa_acct_***-serial_no = 02.
          wa_acct_***-gl_account = '0006360100'.
          wa_acct_***-co_area  = '1000'.
          wa_acct_***-costcenter = 'KC010000'.
          APPEND wa_acct_*** TO i_acct_***.
          wa_acct_assx-po_item = 10.
          wa_acct_assx-serial_no = 01.
          wa_acct_assx-po_itemx = c_x.
          wa_acct_assx-serial_nox = c_x.
          wa_acct_assx-gl_account = c_x.
          wa_acct_assx-co_area  = c_x.
          wa_acct_assx-costcenter = c_x.
          APPEND wa_acct_assx TO i_acct_assx.
          wa_acct_assx-po_item = 10.
          wa_acct_assx-serial_no = 02.
          wa_acct_assx-po_itemx = c_x.
          wa_acct_assx-serial_nox = c_x.
          wa_acct_assx-gl_account = c_x.
          wa_acct_assx-co_area  = c_x.
          wa_acct_assx-costcenter = c_x.
          APPEND wa_acct_assx TO i_acct_assx.
          wa_services-pckg_no = 20.
          wa_services-line_no = 2.
          wa_services-service = wa_input_file-column9.
          wa_services-quantity = '100'.
          wa_services-gr_price = '100'.
          wa_services-userf1_txt = wa_input_file-column13.
          APPEND wa_services TO i_services.
          wa_srvacc-pckg_no = 20.
          wa_srvacc-line_no = 1.
          wa_srvacc-serno_line = 02.
          wa_srvacc-serial_no = 02.
          wa_srvacc-percentage = 100.
          APPEND wa_srvacc TO i_srvacc.
        ENDIF.
      ENDLOOP.
      CALL FUNCTION 'BAPI_PO_CREATE1'
        EXPORTING
          poheader                     = wa_header
          poheaderx                    = wa_headerx
      POADDRVENDOR                 =
      TESTRUN                      =
      MEMORY_UNCOMPLETE            =
      MEMORY_COMPLETE              =
      POEXPIMPHEADER               =
      POEXPIMPHEADERX              =
      VERSIONS                     =
      NO_MESSAGING                 =
      NO_MESSAGE_REQ               =
      NO_AUTHORITY                 =
      NO_PRICE_FROM_PO             =
       IMPORTING
         exppurchaseorder             = ws_po
      EXPHEADER                    =
      EXPPOEXPIMPHEADER            =
       TABLES
         return                       = i_return
         poitem                       = i_poitem
         poitemx                      = i_poitemx
      POADDRDELIVERY               =
         poschedule                   = i_poitem_sch
         poschedulex                  = i_poitem_schx
         poaccount                    = i_acct_***
      POACCOUNTPROFITSEGMENT       =
         poaccountx                   = i_acct_assx
      POCONDHEADER                 =
      POCONDHEADERX                =
      POCOND                       =
      POCONDX                      =
      POLIMITS                     =
      POCONTRACTLIMITS             =
         poservices                   = i_services
         posrvaccessvalues            = i_srvacc
      POSERVICESTEXT               =
      EXTENSIONIN                  =
      EXTENSIONOUT                 =
      POEXPIMPITEM                 =
      POEXPIMPITEMX                =
      POTEXTHEADER                 =
      POTEXTITEM                   =
      ALLVERSIONS                  =
      POPARTNER                    =
      break gbpra8.
      LOOP AT i_return INTO wa_return.
      ENDLOOP.
    ENDFORM.                    " split_data
    *&      Form  conversion_output
          Conversion exit input
    FORM conversion_output  USING    p_ip
                            CHANGING p_op.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          input  = p_ip
        IMPORTING
          output = p_op.
    ENDFORM.                    " conversion_output
    <b>Reward points if this helps.
    Manish</b>

  • BAPI for Open Sales Order

    Experts,
    I need a BAPI for list of Sales order against which the invoice has not been generated.  I need to pass date and bapi shall return list of sales order that are not invoiced.
    Thanks
    Harsh

    Hi Frederic
    Sure it does.
    Actually I want to send data from SAP to some .net application. I thought using BAPI would make the job easier.
    Anyways thanks.
    Regards
    Harsh

  • PS: BAPI For Planned Progress and Actual Progress

    Dear All,
                  Is there any BAPI available for Planned Progress and Actual Progress for PS Project.
    Regards,
    Sohail

    Hi,
    Try using this report s_alr_87013532.
    Also for planned and actual progress the table is rpsqt. Could not find any bapi for the progress
    Regards
    Hiren K.Chitalia

  • BAPIs for Vendor Balances

    Hi!
    I need a BAPI for extract the Vendor Balances and other for load the Vendor Balances.
    Do they exist?

    try to search in Se37
    BAPI_AP_ACC_GETBALANCEDITEMS   Vendor Account Clearing Transactions in a given Period
    BAPI_AP_ACC_GETCURRENTBALANCE  Vendor Account Closing Balance in Current Fiscal Year
    BAPI_AP_ACC_GETKEYDATEBALANCE  Vendor Account Balance at Key Date
    BAPI_AP_ACC_GETPERIODBALANCES  Posting Period Balances per Vendor Account in Current Fiscal Year
    regards
    Prabhu

  • Function modules or BAPI for posting plan costs for WBS Element

    Hi all,
    Does anyone know, whether there exists a function module or BAPI for posting plan costs to a WBS Element? K_COSTS_PLAN_PS does not work, because RKP1 is not allowed.
    Greetings

    check
    BAPI_COSTACTPLN_POSTACTINPUT   Activity Input Planning: Posting                
    BAPI_COSTACTPLN_POSTACTOUTPUT  Activity/Price Planning: Posting                
    BAPI_COSTACTPLN_POSTKEYFIGURE  Stat. Key Figure Planning: Postings             
    BAPI_COSTACTPLN_POSTPRIMCOST   Primary Cost Planning: Postings                 
    BAPI_PDTRANSCO_POSTPRIMCOST    Transfer of Planning Data: Post Primary Costs   
    K40C                           CO Actual Postings, Manual                      
    BAPI_ACC_PRIMARY_COSTS_POST    Accounting: Post Primary Costs                  
    BAPI_COPAACTUALS_POSTCOSTDATA  BAPI Operating Concern: Post Costing-Based Actua
    BAPI_PRIM_COST_CHECK_AND_POST  Primary Costs: Formal Parameter Check           
    S@meer

  • IDOC/BAPI for Production order creation from Legacy system

    Hi all
    We are using an interface to create Production orders from legacy to SAP. Would you recommend an IDOC or a BAPI to create Production orders. If IDOC or BAPI then could you please mention which one?
    thanks a bunch

    Hi John,
    For your purposes, please use BAPI for production order creation from legacy system. There is no standard inbound IDoc available to use. SAP has an IDoc for outbound interface only (message type LOIPRO).
    If there is an inbound IDoc available, I would recommend to use an IDoc.
    IDoc technology has excellent error handling and will allow you to reprocess an error (if any).
    BAPI is also good approach to use and fast in term of  processing.
    For BAPI approach, you can use BAPI BAPI_PRODORD_CREATE.
    Hope this will help.
    Regards,
    Ferry Lianto

  • Bapi for vendor payment with details of tunover and blocked payment

    Dear all
    I want to know whether any BAPI available for the details of vendor payment made and the open item with  blocked payment (with the reason for the blocked payment) and the turnover of the vendor for a particular fiscal year...................
    The client want to get the output as mentioned below.
    e.g...
    PO no : 45629810
    Inv.No : 73409 (Vendor's Invoice no.)
    Payment : Paid amt with date and details
    Payment : Outstanding (Due and Over Due with no.of days)
    Blocked Payment : Amt with the reason for blocking the payment.
    Turn Over : Total turn over for that fiscal year.
    This is an urgent req. from my client,i will be very grateful if any one can  help me over this issue ..............
    Appreciate for any relevant answers and suggestion ...........
    I am in ECC 6.0
    Regards
    Praveen

    Hello Raj,
    Unfortunately there is no BAPI for payment detals and other company code data. The only possibility is via direct input (external data transfer).
    Please have a look at the following Easy-Access-path:
    SAP Menu
    -> Accounting
      -> Bank Applications
       -> Loans Management
        -> Environment
         -> External Data Transfer
    Within this menu entry you find diverse functions. Please start the function KCLJ to transfer data. Before you can do this you need to
    prepare the transfer by creating your own transfer structure and so on. You can get further information on what to do here by navigating to
    "Help   > Application help" within transaction KCLJ. From here you get to the right area of SAP library.
    Thanks Amber

  • Bapi for posting IR line item at a time

    Hi....
    Do we have a bapi for posting invoive receipt line item wise instead of posting the PO at a time......this wud be more precise for my requirement.....presently i'm using bapi_acc_document_post but this wud clear the document with single document number.....but i want it to be posted line item wise to see the amount individually item wise instead of combined one....similar to what we have in the IR which shows amount of individual items........

    This is an old bug that keeps popping up:
    https://forums.lenovo.com/t5/T400-T500-and-newer-T-series/Vertical-scrolling-got-reset-everytime-I-use-Ultra-Nav-to-scroll/td-p/343477

  • Help Rgd. BAPI for Creation of Inbound delivery Document

    Hi all,
    I need a Bapi to create inbound delivery document without using PO reference. I have seen the below BAPIs. i) BAPI_IBDLV_CREATE_FROM_OBDLV, 
    ii) BAPI_GOODSMVT_CREATE. I am not sure whether they are for creating inbound delivery document without using PO reference.
    It will be of great use if anyone can give me the BAPI for the purpose and the mandatory parameters or sample test data for the BAPI.
    Thanks in Advance,
    Rakesh.

    If you create the inbound delivery->check the purchase order in the tabstrip "Confirmations" on item level. There are three fields: "Confirmation control key", "Order acknowl." and "acknowl. required".
    Ckeck if there is a value in "confirmation control key".
    You should get the same error if you try to create VL31N in dialog mode, not only by using the bapi.
    Rgds,
    JP

  • BAPI for changing delivery date and delivery time fields in LIKP table

    Hi All,
         Is there any BAPI or function module to change the delivery date and delivery time in LIKP table ?
    Please tell me experts if exists.
    Thank you,
    Raghu.

    try these:
    BAPI/FM to update LIKP and VTTK tables
    http://sap.ittoolbox.com/groups/technical-functional/sap-dev/bapi-for-changing-sales-headertable-likp-662800

  • BAPI for J1IJ depot excise invoice required

    Hi All,
    Please let me know the BAPI to create depot excise invoice with J1IJ from a delivery.This require to automate the process.
    Please let me know the parameters also.
    Thanks'
    Mukul Kumar

    Hi Mukul,
    CIN does not support any BAPIs for goods receipts and excise updates.
    However, CIN uses MB_MIGO_BADI definition and CIN_PLUG_IN_TO_MIGO implementation. You can create multiple implementations of this BAdI. You can use the same BAdI for single step capture and post of excise invoice in MIGO.
    Regards,
    Rajasree..

  • BAPI -for Creating EXCISE INVOICE AT DEPOT  tcode 'J1IG

    Hi All,
    Is there any  BAPI for Excise Invoice Creation at depot Tcode is J1IG
    Thanks,
    Satishreddy

    Hi,
    Please try this Function Module
    J_1I4A_CREATE_EXCISE_INVOICE
    Hope it helps.
    Regards
    Hiren K.Chitalia

Maybe you are looking for

  • My macbook will not boot up, help?

    my macbook has a battery problem. Last year my hedgehog peed on my laptop, shorting out the battery and other things. i got the computer fixed (they scraped out all the corroded urine) but not the battery. now whenever i unplug the computer from the

  • Airplay works for phots and video, but not music on 2nd gen touch

    Upgraded to 4.2 on 2nd gen touch. I can send photos and videos/movies to AppleTV via Airplay, but not music. I can select AppleTV when playing a song on Touch and the music stops playing from Touch, but never plays from AppleTV. Audio works just fine

  • Please, I need help in this,How to make a tree control appear from right to left ??

    i working on Arabic project in which we use a tree control and i  want it to display its branches from right to left . i tried to rotate it but it doesn't work because the disclosure triangle still appear on the left . i ask if there is any thing to

  • Safari Problems Since New Version

    So I'm someone who actually likes using Safari and I used to experience very few problems with it. Until recently. This started happening as soon as Apple released the new version (can't remember the version number), the one with the improved reader

  • Using Bookmark Names to create Custom Stamps

    Hi all,   I am a VB programmer that is struggling with a task in JS.  I am trying to do 1 of 2 things:  I would prefer #2. 1.Create a custom stamp using the filename. or 2.Create a custom stamp using the bookmark name (which in turn will be the filen