FB01 Recording

Hi Experts!
We need to post documents by recording FB01 in LSMW. In this I have a few doubts.
1. How feasible it is to record FB01? I feel it is mostly not recommended. But for our requirement, we can't go for standard batch input method.
2. Suppose, we record FB01 with 2 line items, then can we use the same recording to post a doc with >2 line items?
3. We created a recording with 2 line items, but when we were uploading a file, it was taking the data in incorrect way. In other words, I recorded by posting a document with 2 line itens. And in file also I am giving 2 entries for one document. But this is trying to post a document for each entry in the file and hence we are getting some errors. How can this be solved?
Kindly suggest on these.
Thanks a lot.
Note: Same posted in ABAP General, so posting in the correct

if cost = 'X' and record-mwskz <> ''.
      perform bdc_field       using 'BSEG-MWSKZ'
                                record-mwskz.
    endif.
    perform bdc_field       using 'BDC_OKCODE'
                    '=ENTE' .
   IF cost = 'X'.
     PERFORM bdc_field       USING 'COBL-KOSTL'
                              record-kostl.
   ENDIF.
   IF cost = 'X'."record-newbs = '21' OR record-newbs = '31'  OR cost = 'X'.
     PERFORM bdc_field       USING 'BSEG-MWSKZ'
                                   v_mwskz.
   ENDIF.
  elseif   record-newbs = '39' or record-newbs = '29' or record-newbs = '19' or record-newbs = '09'.
    perform bdc_dynpro      using 'SAPMF05A' '0304'.
    perform bdc_field       using 'BDC_OKCODE'
                  '=ENTER'.
    perform bdc_field       using 'BSEG-WRBTR'
                            record-wrbtr.
    if record-zfbdt <> ''.
      perform bdc_field       using 'BSEG-ZFBDT'
                                       record-zfbdt.
    endif.
    perform bdc_field       using 'RF05A-NEWUM'"check
                                   record-newum.
    perform bdc_field       using 'BSEG-SGTXT'
                               record-sgtxt.
    perform bdc_field       using 'BSEG-ZUONR'
                         record-zuonr."***
    if record-zterm <> ''.
      perform bdc_field       using 'BSEG-ZTERM'
                             record-zterm.
    endif.
    perform bdc_field       using 'BDC_OKCODE'
                     '=ENTER'.
   IF cost = 'X'.
     PERFORM bdc_field       USING 'COBL-KOSTL'
                              record-kostl.
   ENDIF.
   IF cost = 'X'."record-newbs = '21' OR record-newbs = '31'  OR cost = 'X'.
     PERFORM bdc_field       USING 'BSEG-MWSKZ'
                                   v_mwskz.
   ENDIF.
    perform bdc_field       using 'BDC_OKCODE'
                    '=ENTE' .
  endif.
  perform bdc_field       using 'BDC_OKCODE'
                  '=ENTE' .
  perform bdc_field       using 'BDC_OKCODE'
                                      '=BU'.
  perform bdc_dynpro      using 'SAPLKACB' '0002'.
  perform bdc_field       using 'BDC_CURSOR'
                                'COBL-PRCTR'.
  perform bdc_field       using 'COBL-PRCTR'
                           record-prctr.
  if cost = 'X'  and record-kostl <> ''.
    perform bdc_field       using 'COBL-KOSTL'
                             record-kostl.
  endif.
  perform bdc_dynpro      using 'SAPLSPO4' '300'.
  perform bdc_field       using 'BDC_OKCODE'
                                '/ECANC'.
  perform bdc_dynpro      using 'SAPMF05A' '0700'.
  perform bdc_field       using 'BDC_OKCODE'
                  '=ENTE' .
  perform bdc_field       using 'BDC_OKCODE'
                                     '=BU'.
PERFORM bdc_transaction USING 'FB01'.
  call transaction 'FB01' using bdcdata mode 'E' messages into bdcmess.
  if sy-subrc <> 0.
    move rec_no to error-record.
    append error.
  endif.
  post = 'X'.
  clear bdcdata.
  refresh bdcdata.
CLEAR record.
endform.                    " POST

Similar Messages

  • How to delete Remittance Advice through FB01 - which User exit or BADI?

    I have created a BDC program for transaction FB01 to create an FI posting.  During this BDC session, i need to delete the associated remittance advice using the function REMADV_DELETE.
    Is there a user exit or BADI that i can use to call REMADV_DELETE once the FI posting is successful?
    Thanks,
    Jay

    Jay,
    In BTE there are two types of exit - Publish and Subscribe (P&S) and Process.  Generally P&S give access to read data from a transaction and trigger your own processing as a result, while Process give access to change parts of the data in the SAP transaction.  For what you want, P&S probably gives the functionality you need.
    You need to copy the sample function to a Z function in a Z function Group.  Put in your code, and activate the function and function group.  As an initial test just a break-point in the code is useful to see when the exit executes and what data is available.
    Then in transaction FIBF you need to insert customising to link in and activate the exit.
    In the FIBF transaction, go to menu option Settings>Products>Of a Customer.  Select New Entries and create a Z... entry with appropriate text. Leave other fields at this time and save.
    Go to Settings>P/S Modules>Of a Customer. Select New Entries and create an entry for the relevant event number with the Z product you just created and add your function module name. Country and Appl can be filled or left blank for "All". Save the entry.
    Go back to the Settings>Products>Of a Customer entry and selct the activate check box and save the entry.
    Your function should now get executed at the relevant point.  Remember this will get executed in all posting transactions, so include appropriate checks for your transaction code, document type, etc.
    One note.  Transaction FB01 performs some of its updates using "IN UPDATE TASK" so some records may not be created at the time some exits are executed.  In the old style debugger a commit is performed when you debug so the update is triggered, but then when you run without the debugging things work differently.  The new style debugger lets you debug these exits without the commit and thus gives a better picture of what will really happen.
    Andrew

  • Duplicate entries getting posted using FB01

    Hi All,
    I am facing a very strange problem which I have never heard of before.
    There is a report program which picks up an input file from the application server and posts the entries. This input file will contain all the details about header record, vendor line items and G/L line items.
    The report checks for duplicate entries comparing the reference number and the vendor. It discards the duplicate entries. It does not post duplicate entries.
    Now, the input file contains the reference number only once. It also has multiple line items for that refernce. But has posted two identical documents having same reference, company code, etc. The only thing that is different is the document number and the time of entry. There is just a few seconds gap between the posting of the two entries.
    Ideally FB01 should also not allow to post such identical entries.
    Please suggest possible reasons for such postings.
    Thanks & Regards,
    Namrata

    Hi,
    Manually everything is working fine. Also through this report everything works fine always except for this case which happened.
    The input file had a lot of references for posting. But just one got duplicated. So, I was just wondering what could have gone wrong.
    Could it be because of some database commit or due to some memory buffer refresh which did not happen by mistake.
    I'm just trying to figure out some possible causes for such a thing.
    Your inputs and thoughts are welcome.
    Thanks & Regards,
    Namrata

  • FB01 upload using LSMW

    Hi
    Iam uploading FB01 data using LSMW.
    I maintained two files, one for Header Data and one for Item Data
    but only header data was written after reading
    can any one give me the steps regarding this
    Thanka in advance
    venkat

    Hi,
    LSMW will have a Indocator for headr and itam, i do not remember the correct field, but it will have an indicator, check the fields, there will be a single charecter lenght field, that should be the indicator, and using that we can write the logic.
    check that single charecter field, it that is X that means the header record is processed, and do the items.
    and, this is another way, try this out also
    YOu can do this in "Define Source Structures" step,
    the HEADER is defined first,
    then the DETAIL below the HEADER.
    add the fields to the structures.
    Both should have some common key field
    Please take care that the name of the common field is the same.
    Once you do this it is linked. The you have a header and item corresponding to that header. then run the LSMW as you would.
    Regards
    Sudheer

  • BDC for AR Posting (Tcode - FB01)

    Dear All,
    I am unable to post multiple line items while postnig AR Invoice using BDC recording of FB01.
    Can anyone provide me the BDC program code to post multiple line items.
    Thanks in Advance,
    Harish

    hi,
    please check your document type with tcode oba7
    field cust./vend. check (t003-XKKPR) -> set value = X
    pls reward useful answers
    thx.
    Andreas

  • FB01 uploading problem with posting keys

    Hi Gurus!
    I created this program to upload the FB01 transaction froma  csv file using 'BAPI_ACC_DOCUMENT_CHECK'.
    Everything seems to be working fine except for the fact that even when my csv file has the posting key of 31 for the  vendor and 40 for the gl it picks up 21 and 50 from somewhere and posts that which is wrong. I am not sure why this is happening and where its picking up the posting keys from inspite of the file indicating 31 and 40 respectively.
    My file is as follows:
    02232010;KR;2000;02222010;;CAD;154085;009571;31;925049;20706.84;V005;02222010;C;213728;40;3998;20706.84;1;EA;002;730019;730019 and as you see the 31 and 40 are mentioned in the file but after i run teh program and see the FB03 for the postings it shows me as follows.
    2000     1     000001     21     2000     Trade Accts Payable                    6,935.41     CAD               730019               
    2000     2     000002     50     3998     Trade AR Conversion                    6,935.41-     CAD          730019     730019     
    Could anyone please tell me why is it picking up other posting key istead of mine being provided in the file.
    Thanks

    I followed this:
    ***Vendor account check***
        CLEAR wa_ap.
        wa_ap-itemno_acc         = 1.                           "Item No
        wa_ap-vendor_no         = tw_upload-newko.              "Vendor account no
        wa_ap-item_text         = tw_upload-sgtxt.
        APPEND wa_ap TO ta_ap.
    ***General Ledger account check***
        CLEAR wa_gl.
        wa_gl-itemno_acc         = 2.                           "Item No
        wa_gl-gl_account         = tw_upload-newko_2.           "General ledger account
        wa_gl-item_text          = tw_upload-sgtxt_2.
    *    wa_gl-fis_period         = tw_upload-monat.
        wa_gl-pstng_date         = wa_header-pstng_date.
        wa_gl-costcenter         = tw_upload-kostl.             "Cost center
        wa_gl-profit_ctr         = tw_upload-prctr.             "Profit center
        APPEND wa_gl TO ta_gl.
    ***Currency check***
        CLEAR wa_curr.
        wa_curr-itemno_acc       = 1.
        wa_curr-currency         = tw_upload-waers.
        wa_curr-amt_doccur       = tw_upload-wrbtr .
        APPEND wa_curr TO ta_curr.
        CLEAR wa_curr.
        wa_curr-itemno_acc       = 2.
        wa_curr-currency         = tw_upload-waers.
        wa_curr-amt_doccur       = tw_upload-wrbtr_2 * -1 .
        APPEND wa_curr TO ta_curr.
    **Bapi check for the record to post
        CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
          EXPORTING
            documentheader = wa_header
          TABLES
            accountgl      = ta_gl
            currencyamount = ta_curr
            return         = ta_return
            accountpayable = ta_ap. " If return contains no errors then post documents

  • FB01 - Really appreciate your suggestion

    Hi Everybody,
    I have been trying out different ways of posting a FI document FB01 from
    non-sap system(SAP Dot NET connector). As per my understanding the following are the best ways.
    Direct Input (Old method and no control)
    BDC (More authorizations needed for background user and new program)
    IDoc
    Client is only willing to send batch files in the required format.
    Out of the above 3 ways, as IDOC is comparatively new and efficient way, I opted for IDOC. Could anyone please tell me whether my decision was right?
    Client does not want to make any new developments in SAP for this
    interface for example he does not want to create new BDC program etc..
    With minimal customizing or modifications how can I post FI batch
    records from Non-SAP to SAP?
    Can I process multiple FI documents in one IDOC or do I need to create one IDOC for each FI document?
    Please let me know if you need more details.
    Thanks in Advance. I really appreciate any help.
    - Kriss

    Hi Kriss,
    When you use IDOC for distribution you need all the steps.
    Please go through the below thread and links you will get all the details.
    Re: How to configure idoc PAYCHK00
    http://help.sap.com/saphelp_nw04/helpdata/en/0b/2a6702507d11d18ee90000e8366fc2/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/0b/2a61ca507d11d18ee90000e8366fc2/content.htm
    Regards,
    Atish

  • Re: ICR - Duplicate records in FBICRC003A

    Hi Ralph,
    It seems that FBICA3 creates duplicate records in FBICRC003A if assigned items were subsequently unassigned. I believe this is due to program error. These are the steps that I went through to get this error:
    1) Post cross-company FI document (FB01)
    2) Run FBICS3
       FBICRC003A records 1 and 2 were created with RTYPE = 'blank'
    3) Run FBICA3
       FBICRC003A records 3 and 4 were created with RTYPE = '2'
    4) Run FBICR3 and unassign the items
       FBICRC003A records 3 and 4 were changed with RTYPE = '1'
       ZUONR was set to the record number of the unassigned record (ie: 1 or 2)
    5) Run FBICS3
    6) Run FBICA3
       FBICRC003A records 3 and 4 were changed with RTYPE = '2'
       Duplicate FBICRC003A records 5 and 6 were created with RTYPE = '2'
    Are you aware of this issue ? FYI, OSS notes 863630 and 1062292 are both implemented in our system.
    Thank you.
    Regards,
    Siong

    Hello Siong,
    This is not a known issue. I suggest that you create a service ticket.
    Best regards,
    Ralph

  • Posting FI  documents to FB01 transaction

    Hi ,
    My program collects data from database tables and sends the final data to a file in SAP directory.
    Now my requirement is to post this data into FB01 transaction.
    When the program runs, the following entry is posted
           Dr   210001023        
           Cr   229001017.
    SO which FM do I need to use to post these two GL accounts?Is there any other method to do so.
    My file contains Vendor info and check details like no, date,amount...
    I appreciate quick response.
    Thanks in Advance.
    Swathi.

    Hi Rhea,
    Have a look at my program below. Its has no customer no's.but  dr and cr accounts.
    *---SELECTION-SCREEN
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS: p_zbukr LIKE payr-zbukr OBLIGATORY,      " Paying Company
                p_hbkid LIKE payr-hbkid OBLIGATORY,      " House Bank
                p_hktid LIKE payr-hktid OBLIGATORY,      " Account ID
                p_file LIKE rlgrap-filename OBLIGATORY.  " Output file name
    SELECT-OPTIONS: s_prundt FOR sy-datum OBLIGATORY NO-EXTENSION,
                                                         " Previuos run date
                    s_crundt FOR sy-datum NO-EXTENSION.
    " Current run date
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS      p_chkvd AS CHECKBOX DEFAULT 'X'.     " Update TVARV
    SELECTION-SCREEN COMMENT 04(79) text-014.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 01(64) text-013 FOR FIELD p_mon.
    PARAMETERS  p_mon(2) TYPE n DEFAULT '24'.   " Months considered
    " for abandoned period of uncashed checks
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END   OF BLOCK b1.
    *---INITIALIZATION
    INITIALIZATION.
    Initialize Unix File Path
      PERFORM initialize_filepath.
    *---AT SELECTION-SCREEN
    AT SELECTION-SCREEN.
    Selection Screen Validations
      PERFORM validations.
    Populate current extraction date
      PERFORM get_current_date.
    *---START-OF-SELECTION
    START-OF-SELECTION.
    Get data from PAYR
      PERFORM get_payr.
    Get data from VF_KRED
      PERFORM ger_vf_kred.
    Process data
      PERFORM process_data.
    *---END-OF-SELECTION
    END-OF-SELECTION.
      IF f_data IS INITIAL.
    Transfer data to file
        PERFORM transfer_data.
    Write report
        PERFORM write_report.
      ENDIF.
    *---PAGE HEADING
    TOP-OF-PAGE.
    Write the Page Heading
      PERFORM page_heading.
    *&      Form  Initialize_filepath
          Initialize Unix File Path
    FORM initialize_filepath.
    Output File
      CONCATENATE '/int/'
                  sy-sysid
                  sy-mandt
                  '/out/'
                  INTO p_file.
    ENDFORM.                    " Initialize_filepath
    *&      Form  Validations
          Selection Screen Validations
    FORM validations.
    Local variable
      DATA: l_text(5).  " variable to hold 5 char data
    Validate paying company
      SELECT SINGLE bukrs INTO l_text FROM t001 WHERE bukrs = p_zbukr.
      IF sy-subrc <> 0.
        MESSAGE e003 WITH 'Invalid Paying Company'(002) p_zbukr.
      ENDIF.
    Validate House bank
      SELECT SINGLE hbkid INTO l_text FROM t012 WHERE bukrs = p_zbukr AND
                                                      hbkid = p_hbkid.
      IF sy-subrc <> 0.
        MESSAGE e003 WITH 'Invalid Hoouse Bank'(003) p_hbkid.
      ENDIF.
    Validate Account Id
      SELECT SINGLE hktid INTO l_text FROM t012k WHERE bukrs = p_zbukr AND
                                                       hbkid = p_hbkid AND
                                                       hktid = p_hktid.
      IF sy-subrc <> 0.
        MESSAGE e003 WITH 'Invalid Account ID'(004) p_hktid.
      ENDIF.
    Validate File name
      PERFORM validate_filename.
    ENDFORM.                    " Validations
    *&      Form  validate_filename
          Validate File name
    FORM validate_filename.
      DATA : l_len TYPE i.
      l_len = strlen( p_file ).
      IF p_file CA space.
        IF sy-fdpos < l_len.
          MESSAGE e003 WITH
            'File name should not contain spaces'(005).
        ENDIF.
      ENDIF.
      IF p_file CA '\'. "File name should not contain '\'.
        MESSAGE e003 WITH
          'File name should not contain \'(006).
      ENDIF.
      IF p_file0(1) = '/' AND p_file1(127) = space.
        MESSAGE e003 WITH
          'File name should not contain only /'(007).
      ENDIF.
    ENDFORM.                    " validate_filename
    *&      Form  get_payr
          Get data from PAYR
    FORM get_payr.
      SELECT zbukr
             hbkid
             hktid
             checf
             laufd
             lifnr
             vblnr
             zaldt
             waers
             rwbtr FROM payr INTO TABLE t_payr
             BYPASSING BUFFER
             WHERE zbukr = p_zbukr AND
                   hbkid = p_hbkid AND
                   hktid = p_hktid AND
                   zaldt IN s_crundt AND
                   bancd = '00000000' AND
                   voidr = '00'.
      IF sy-subrc = 0.
        SORT t_payr.
    Get the sending company code from REGUH
        SELECT laufd
               zbukr
               lifnr
               vblnr
               absbu FROM reguh INTO TABLE t_reguh
               BYPASSING BUFFER
               FOR ALL ENTRIES IN t_payr
               WHERE laufd = t_payr-laufd AND
                     xvorl = space AND
                     zbukr = t_payr-zbukr AND
                     lifnr = t_payr-lifnr AND
                     vblnr = t_payr-vblnr.
        IF sy-subrc = 0.
          SORT t_reguh.
        ENDIF.
      ELSE.
        MESSAGE i003 WITH 'No data exists for the given selection'(011).
        f_data = c_f.
        STOP.
      ENDIF.
    ENDFORM.                    " get_payr
    *&      Form  ger_VF_KRED
          Get data from VF_KRED
    FORM ger_vf_kred.
      IF NOT t_reguh[] IS INITIAL.
        SELECT lifnr
               bukrs
               name1
               ort01
               ort02
               pstlz
               regio
               stcd1
               stras
               qsrec
               adrnr
               FROM vf_kred INTO TABLE t_lfa1
               BYPASSING BUFFER
               FOR ALL ENTRIES IN t_reguh
               WHERE lifnr = t_reguh-lifnr AND
                     bukrs = t_reguh-absbu.
        IF sy-subrc = 0.
          SORT t_lfa1.
        ELSE.
          MESSAGE i003 WITH 'No vendor data exists'(012).
        ENDIF.
      ENDIF.
    ENDFORM.                    " ger_VF_KRED
    *&      Form  process_data
          Process data
    FORM process_data.
      LOOP AT t_payr.
    Get the sending company code from T_REGUH
        READ TABLE t_reguh WITH KEY laufd = t_payr-laufd
                                    zbukr = t_payr-zbukr
                                    lifnr = t_payr-lifnr
                                    vblnr = t_payr-vblnr
                                    BINARY SEARCH TRANSPORTING absbu.
        IF sy-subrc <> 0.
          CLEAR t_reguh-absbu.
        ENDIF.
        clear t_lfa1.
    Get the vendor data from T_LFA1
        READ TABLE t_lfa1 WITH KEY lifnr = t_payr-lifnr
                                   bukrs = t_reguh-absbu
                                   BINARY SEARCH.
        IF sy-subrc <> 0.
          CLEAR t_lfa1.
          SELECT SINGLE name1 stcd1 adrnr INTO
                       (t_lfa1-name1, t_lfa1-stcd1, t_lfa1-adrnr)
                       FROM lfa1 WHERE lifnr = t_payr-lifnr.
          IF sy-subrc <> 0.
            CLEAR t_lfa1.
          ENDIF.
        ENDIF.
        clear t_address.
        clear : t_lfa1-ort01,
                t_lfa1-ort02,
                t_lfa1-pstlz,
                t_lfa1-regio,
                t_lfa1-stras.
    Vendor Address
      select single city1
                    str_suppl1
                    post_code1
                    region
                    street
               from adrc into t_address
               where addrnumber = t_lfa1-adrnr.
      if sy-subrc = 0.
        move-corresponding t_address to t_lfa1.
      endif.
    Vendor Type
        CASE t_lfa1-qsrec.
          WHEN c_01.
            t_file-vend_type = c_s.
          WHEN c_07 OR c_20.
            t_file-vend_type = space.
    Clear Vendot TIN
            CLEAR t_lfa1-stcd1.
          WHEN OTHERS.
            t_file-vend_type = c_f.
        ENDCASE.
    Vendor TIN
        t_file-vend_tin = t_lfa1-stcd1.
    Vendor Name
        t_file-vend_name = t_lfa1-name1.
    Mail Address1
        t_file-addr1 = t_lfa1-stras.
    Mail Address2
        t_file-addr2 = t_lfa1-ort02.
    City
        t_file-city  = t_lfa1-ort01.
    State
        t_file-state = t_lfa1-regio.
    Zip Code
        t_file-zip   = t_lfa1-pstlz.
    Check ID
        t_file-check_id = c_ms08.
    Check Number
        t_file-check_no = t_payr-checf.
    Application Description
        t_file-appl_desc = c_app_desc.
    Check Date
        t_file-check_dt = t_payr-zaldt.
    *TPR 1944 : Begin   "Vinay
    Check Amount sign
       IF T_PAYR-RWBTR GE 0.
         T_FILE-CHECK_SIGN = C_POS.
       ELSE.
         T_FILE-CHECK_SIGN = C_NEG.
       ENDIF.
        IF t_payr-rwbtr GE 0.
          t_file-check_sign = c_neg.
        ELSE.
          t_file-check_sign = c_pos.
        ENDIF.
    *TPR 1944: End "Vinay
    Check Amount
        UNPACK t_payr-rwbtr TO t_file-check_amt1.
        t_file-check_amt2 = t_file-check_amt1.
        t_file-amt = t_payr-rwbtr.
        t_file-vend_no = t_payr-lifnr.
        t_file-waers = t_payr-waers.
        APPEND t_file.
        CLEAR t_file.
      ENDLOOP.
    ENDFORM.                    " process_data
    *&      Form  transfer_data
          Transfer data to file
    FORM transfer_data.
      DATA : l_pgm_id LIKE sy-repid,
             l_file_mode LIKE pppch-acces VALUE 'A'.
      l_pgm_id = sy-repid.
    Open data file
      CALL FUNCTION 'ZZ_OPEN_OUTBOUND_INTERFACE'
        CHANGING
          file_name                     = p_file
          pgm_id                        = l_pgm_id
          mode                          = l_file_mode
      FILE2                         =
      FILE3                         =
      FILE4                         =
      FILE5                         =
      FILE6                         =
      FILE7                         =
      FILE8                         =
      FILE9                         =
      FILE10                        =
      ABEND_ON_ERROR_IF_SPACE       =
       EXCEPTIONS
         error                         = 1
         OTHERS                        = 2
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    Transfer data to the file
      LOOP AT t_file.
        TRANSFER t_file+0(1221) TO p_file.
        v_count = v_count + 1.
      ENDLOOP.
    Close data file
      CALL FUNCTION 'Z_CLOSE_INTERFACE_FILE'
           EXPORTING
                pgm_id = l_pgm_id.
    ENDFORM.                    " transfer_data
    *&      Form  get_current_date
          Populate current extraction date
    FORM get_current_date.
      DATA: l_date LIKE sy-datum,
           l_mon(2) TYPE n,
           l_months TYPE i.
      l_mon = sy-datum+4(2).
      l_mon = l_mon - 1.
      l_date = sy-datum.
      l_date+4(2) = l_mon.
      CALL FUNCTION 'SG_PS_GET_LAST_DAY_OF_MONTH'
           EXPORTING
                day_in            = l_date
           IMPORTING
                last_day_of_month = l_date
           EXCEPTIONS
                day_in_not_valid  = 1
                OTHERS            = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    Calculate date with no.of months considered for abandoned period of
    uncashed checks
      l_months = p_mon * -1.
      CALL FUNCTION 'MONTH_PLUS_DETERMINE'
           EXPORTING
                months  = l_months
                olddate = l_date
           IMPORTING
                newdate = s_crundt-high.
    Begin of D02K921571
      CALL FUNCTION 'SG_PS_GET_LAST_DAY_OF_MONTH'
           EXPORTING
                day_in            = s_crundt-high
           IMPORTING
                last_day_of_month = s_crundt-high
           EXCEPTIONS
                day_in_not_valid  = 1
                OTHERS            = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    End of D02K921571
      REFRESH s_crundt.
      s_crundt-low = s_prundt-high + 1.
      s_crundt-sign = 'I'.
      s_crundt-option = 'BT'.
      APPEND s_crundt.
      CLEAR s_crundt.
    ENDFORM.                    " get_current_date
    *&      Form  write_report
          Write Report
    FORM write_report.
    Selection Report
      PERFORM select_report.
    Audit Report
      PERFORM audit_report.
    Detail Report
      PERFORM detail_report.
    ENDFORM.                    " write_report
    *&      Form  Page_heading
          page heading
    FORM page_heading.
      FORMAT COLOR COL_HEADING INTENSIFIED ON.
      ULINE.
      WRITE: /1 sy-vline,
              2  sy-repid,
              65 'ABBOTT LABORATORIES'(015) CENTERED,
                146 sy-datum,
                156 sy-vline.
      WRITE: /1 sy-vline,
              2   sy-sysid,
              5  '/',
              6  sy-mandt,
              59 'SAP to Tracker Outbound Interface'(016) CENTERED,
              148 sy-uzeit,
              156 sy-vline.
      WRITE: /1 sy-vline,
              2 sy-uname,
              (120) v_title CENTERED,
              145 'Page:'(017), sy-pagno,
              156 sy-vline.
      ULINE.
      IF v_title = 'Detail Report'(030).
        FORMAT COLOR COL_HEADING INTENSIFIED OFF.
        WRITE: /1 sy-vline,
                2 'Paying Company'(031),
                17 sy-vline,
                18 'House Bank'(032),
                29 sy-vline,
                30 'Account ID'(033),
                41 sy-vline,
                42 'Current Extract Range'(034),
                156 sy-vline.
        FORMAT COLOR OFF.
        WRITE:   /1 sy-vline,
                 2 p_zbukr CENTERED,
                 17 sy-vline,
                 18 p_hbkid CENTERED,
                 29 sy-vline,
                 30 p_hktid CENTERED,
                 41 sy-vline.
        LOOP AT s_crundt.
          WRITE: 44 s_crundt-low,
                 58 'to'(035),
                 62 s_crundt-high.
        ENDLOOP.
        WRITE: 156 sy-vline.
        ULINE.
        FORMAT COLOR COL_HEADING INTENSIFIED OFF.
        WRITE: /1 sy-vline,
                2 'Vendor Type'(036),
                14 sy-vline,
                15 'Vendor TIN'(037),
                26 sy-vline,
                27 'Vendor No.'(038),
                38 sy-vline,
                39 'Vendor Name'(039),
                82 sy-vline,
                83 'Vendor State'(040),
                96 sy-vline,
                97 'Check Number'(041),
                118 sy-vline,
                119 'Check Issue Date'(042),
                136 sy-vline,
                137 'Check Amount'(043),
                156 sy-vline.
        ULINE.
      ENDIF.
    ENDFORM.                    " Page_heading
    *&      Form  select_report
          selection-report
    FORM select_report.
      NEW-PAGE.
      v_title = 'Selection Report'(028).
      FORMAT COLOR COL_NORMAL INTENSIFIED ON.
      WRITE: /1 sy-vline,
              2 'Paying company code      :'(018),
              28 p_zbukr,
             156 sy-vline.
      FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
      WRITE: /1 sy-vline,
              2 'House bank               :'(019),
              28 p_hbkid,
             156 sy-vline.
      FORMAT COLOR COL_NORMAL INTENSIFIED ON.
      WRITE:/1 sy-vline,
             2 'Account ID               :'(020),
             28 p_hktid,
            156 sy-vline.
      FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
      WRITE:/1 sy-vline,
             2 'Output file name         :'(021),
             28 p_file,
            156 sy-vline.
      FORMAT COLOR COL_NORMAL INTENSIFIED ON.
      WRITE: /1 sy-vline,
              2 'Previous extraction date :'(022).
      LOOP AT s_prundt.
        WRITE: 28 s_prundt-low,
               42 'to'(035),
               46 s_prundt-high.
      ENDLOOP.
      WRITE: 156 sy-vline.
      FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
      WRITE: /1 sy-vline,
       2 'Current extraction date  :'(023).
      LOOP AT s_crundt.
        WRITE: 28 s_crundt-low,
               42 'to'(035),
               46 s_crundt-high.
      ENDLOOP.
      WRITE: 156 sy-vline.
      FORMAT COLOR COL_NORMAL INTENSIFIED ON.
      WRITE: /1 sy-vline,
       2 'Update TVARV             :'(024),
       28 p_chkvd,
      156 sy-vline.
      FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
      WRITE:   /1 sy-vline,
         2 text-025,
         67 p_mon,
          156 sy-vline.
      ULINE.
    ENDFORM.                    " select_report
    *&      Form  audit_report
          Audit Report
    FORM audit_report.
      NEW-PAGE.
      v_title = 'Audit Report'(029).
      FORMAT COLOR COL_NORMAL INTENSIFIED ON.
      WRITE: /1 sy-vline,
             2 'No. of records extracted          :'(026),
             36 v_count,
             156 sy-vline.
      FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
      WRITE: /1 sy-vline,
             2 'No. of records transferred to file:'(027),
             36 v_count,
             156 sy-vline.
      ULINE.
    ENDFORM.                    " audit_report
    *&      Form  detail_report
          Detail Report
    FORM detail_report.
      DATA : l_inten TYPE i,
             l_date LIKE sy-datum.
      NEW-PAGE.
      v_title = 'Detail Report'(030).
      LOOP AT t_file.
        l_inten = sy-tabix MOD 2.  " for alternate colors in report
        IF l_inten = 0.
          FORMAT COLOR COL_NORMAL INTENSIFIED ON.
        ELSE.
          FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
        ENDIF.
        l_date = t_file-check_dt.
        WRITE: /1 sy-vline,
                2 t_file-vend_type,
                14 sy-vline,
                15 t_file-vend_tin,
                26 sy-vline,
                27 t_file-vend_no,
                38 sy-vline,
                39 t_file-vend_name,
                82 sy-vline,
                83 t_file-state,
                96 sy-vline,
                97 t_file-check_no,
                118 sy-vline,
                119 l_date,
                136 sy-vline,
                137 t_file-amt CURRENCY t_file-waers,
                156 sy-vline.
      ENDLOOP.
      ULINE.
    ENDFORM.                    " detail_report

  • BDC  for FB01  Transaction.

    Hi Experts,
    I am having the bdc recording of the transaction FB01 in shdb transaction.I have converted the recording into an program.I am finding difficulty in Line items posting. As I am new to FI module.
    How to go about for the line item positng with respect to  psoting key is NEWBS.
    Thanks in Advance
    Irfan Hussain

    Hi,
    FB01 is a transaction very nice to learn BDC
    Here a code (with french comment)
    report z_fi_in_01 no standard page heading
                      line-size 80
                      line-count 65.
    *-------------------------------- DATA --------------------------------*
    data : v_infile(200) type c ,              " Chemin physique fich.
           v_periode(4)  type n ,              " Periode
           v_t_code(20)  type c value 'FB01' , " Code transaction.
           v_count(3)    type n ,              " Compteur de poste piec
           v_decimal(1)  type c ,              " Representation decimal
           v_nb_blanc(6) type n ,              " Nb ligne montant nul
           v_date(8)     type c .              " Date comptable
    data : begin of itab_fichier_in occurs 0,
             societe(4)   type c ,                  " Société
             poste(2)     type c ,                  " Poste -> type piece
             centre(8)    type c ,                  " Centre de couts
             compte(10)   type c ,                  " Compte comptable
             code_dc(1)   type c ,                  " Code debit/credit C/D
             montantc(13) type p decimals 2 ,       " Montant credit
             montantd(13) type p decimals 2 ,       " Montant debit
           end of itab_fichier_in.
    data: begin of bdc_tab occurs 100.
            include structure bdcdata.
    data: end of bdc_tab.
    data : begin of itab_piece occurs 0 ,
             typepiece(2) type c ,
             montantc(13) type p decimals 2 ,       " Montant credit
             montantd(13) type p decimals 2 ,       " Montant debit
             solde(13)    type p decimals 2 ,       " Solde
           end of itab_piece.
    *--------------------------- PARAMETERS -------------------------------*
    parameters : p_infile(100) type c
                               default '.dat'
                               lower case
                               obligatory ,
                 p_nom(12) type c
                            default 'Z_PAIE'
                            obligatory ,
                 p_waers like t001-waers
                            obligatory .
    *-------------------------------- MAIN --------------------------------*
    start-of-selection.
    * Recherche des chemins physique à partir des chemins logiques.
      perform p_recherche_chemin.
    * Copie du contenu du fichier dans la table interne ITAB_FICHIER_IN.
      perform p_lecture_input.
    * Test si les données sont bien equilibrées.
      perform p_test_donnee.
    * Ouverture du dossier.
      perform open_bdc using p_nom.
    * Transformation des données type pleiade au format SAP.
      perform p_creation_batch.
    * Fermeture du dossier.
      perform close_bdc.
    * Edition.
      perform p_edition.
    end-of-selection.
    *------------------------------ PROCEDURE -----------------------------*
    *   Procédure P_RECHERCHE_CHEMIN.                                      *
    *   Recherche des chemins de fichiers physiques à partir des chemins   *
    *   de fichiers logiques.                                              *
    form p_recherche_chemin.
    * Fonction de recherche du chemin physique depuis le chemin logique
    * On passe en parametre le nom du fichier.
      call function 'FILE_GET_NAME'
           exporting
                client           = sy-mandt
                logical_filename = 'Z_FI_PAIE_PLEIADE_FILE'
                operating_system = sy-opsys
                parameter_1      = p_infile
           importing
                file_name        = v_infile
           exceptions
                file_not_found   = 1
                others           = 2.
    * Si probleme d ouverture message et on arrete tout.
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        stop.
      endif.
    endform.                               " P_RECHERCHE_CHEMIN
    *   Procédure P_LECTURE_INPUT.                                         *
    *   Ouverture, lecture, fermeture du fichier de paie.                  *
    form p_lecture_input.
      data : v_msg(100)    type c ,     " Message d erreur ouverture fichier
             v_buffer(200) type c.      " Buffer lecture fichier
    * Ouverture du fichier en entrée.
      open dataset v_infile for input in text mode message v_msg.
      if sy-subrc ne space.
        write : /1 'ERREUR FATALE !' color 3,
                   'IMPOSSIBLE D OUVRIR LE FICHIER EN ENTREE :',
                   p_infile ,
                /1 v_msg.
        stop.
      endif.
    * Lecture sequentiele du fichier en entrée.
      do.
        read dataset v_infile into v_buffer.
    *   Test fin de fichier.
        if sy-subrc ne space.
          exit.
        endif.
    *   Transfert du buffer dans la table interne.
        move : v_buffer+6(4)   to v_periode ,
               v_buffer+10(8)  to itab_fichier_in-centre ,
               v_buffer+18(10) to itab_fichier_in-compte ,
               v_buffer+28(2)  to itab_fichier_in-poste ,
               v_buffer+32(1)  to itab_fichier_in-code_dc ,
               v_buffer+33(18) to itab_fichier_in-montantc ,
               v_buffer+51(18) to itab_fichier_in-montantd .
    *   Allimente le code société.
        if     v_buffer+0(2) eq '04'.
          move '1614' to itab_fichier_in-societe.
        elseif v_buffer+0(2) eq '09'.
          move '2826' to itab_fichier_in-societe.
        else.
          write : /1 'Société inconnue ! traitement interrompu !' ,
                     v_buffer+0(2) .
        endif.
    *   On replace la decimale sur le montant.
        itab_fichier_in-montantc = itab_fichier_in-montantc / 100.
        itab_fichier_in-montantd = itab_fichier_in-montantd / 100.
    *   Enregistrement de la ligne dans la table interne ITAB_FICHIER_IN.
        append itab_fichier_in.
        clear  itab_fichier_in.
      enddo.
    * Fermeture du fichier en entrée.
      close dataset v_infile.
    * Trie de la table interne ITAB_FICHIER_IN.
      sort itab_fichier_in by societe poste compte centre.
    endform.                               " P_LECTURE_INPUT.
    *   Procédure P_TEST_DONNEE.                                           *
    *   Verifie si la somme des debits est egale a la somme des credits.   *
    *   Verifie si n y a pas de montant nul.                               *
    *   Verifie que les differents type de piece sont equilibrés entre     *
    *   eux.                                                               *
    *   Force le centre de cout à 91001038 pour les comptes comptables     *
    *   commencent par 481801.                                             *
    form p_test_donnee.
      data : v_montantc(13) type p decimals 2 ,
             v_montantd(13) type p decimals 2 .
    * Cumul les montants debit et credit.
      loop at itab_fichier_in.
        v_montantc = v_montantc + itab_fichier_in-montantc.
        v_montantd = v_montantd + itab_fichier_in-montantd.
      endloop.
    * Test si debit = credit.
      if v_montantc ne v_montantd.
        skip 2.
        write : /1 'ATTENTION LE FICHIER N EST PAS EQUILIBRE !!' color 3.
        skip 2.
        write : /5 'Total montant debit  :',
                   v_montantd ,
                /5 'Total montant credit :' ,
                   v_montantc .
        stop.
      endif.
    * Verifie s il n y a pas de montant nul. Si oui on efface.
      loop at itab_fichier_in.
        if itab_fichier_in-montantc eq space and
           itab_fichier_in-montantd eq space.
          v_nb_blanc = v_nb_blanc + 1.
          delete itab_fichier_in.
        endif.
      endloop.
    * Verifie que les differents postes sont equilibrés.
      clear : v_montantc, v_montantd.
      loop at itab_fichier_in.
        v_montantc = v_montantc + itab_fichier_in-montantc.
        v_montantd = v_montantd + itab_fichier_in-montantd.
        at end of poste.
          if v_montantc ne v_montantd.
            skip 2.
            write : /1 'ATTENTION LE FICHIER N EST PAS EQUILIBRE !!'
                        color 3 ,
                    /1 'Au moins un type de piece n''est pas equilibré.'.
            skip 2.
            write : /5 'Montant debit  :',
                       v_montantd ,
                    /5 'Montant credit :' ,
                       v_montantc .
            stop.
          endif.
          clear : v_montantc, v_montantd.
        endat.
      endloop.
    * Si le compte comptable commence par 481801 on force le centre de
    * couts à 91001038.
      loop at itab_fichier_in
           where compte(6) = '481801'.
        move '91001038' to itab_fichier_in-centre.
        modify itab_fichier_in.
      endloop.
    endform.                               " P_TEST_DONNEE.
    *   Procédure P_CREATION_BATCH.                                        *
    *   Application de regle de gestion :                                  *
    *     - La date est obtenue à partir de la zone période. On prend le   *
    *       dernier jour du mois indiqué dans le fichier en entrée.        *
    *     - Si le poste est PR alors le type de document est AC sinon il   *
    *       est SA.                                                        *
    *     - Si c est un debit la clé est 40, si c est un credit 50.        *
    *     - Le montant du fichier en entrée est exprimé en centime.        *
    form p_creation_batch.
      data : v_totald(13)  type p decimals 2 ,   " Total debit
             v_totalc(13)  type p decimals 2 ,   " Total credit
             v_total(13)   type p decimals 2 ,   " Total general
             v_clef(2)     type n ,              " Clef 50/40
             v_montant(13) type p decimals 2 ,   " Montant temporaire
             v_flag_fin(1) type n .              " Indicateur fin piece
    * Recherche de la date de fin de mois de la periode
      perform p_last_day_of_month using    v_periode
                                  changing v_date.
    * Recherche de la constante utilisateur sur la decimal.
      perform p_decimal.
    * Boucle sur la table interne.
      loop at itab_fichier_in.
    *   Compteur de poste de piece.
        v_count = v_count + 1.
    *   Gestion du cumul des montants.
        if itab_fichier_in-code_dc eq 'D'.
          v_total  = v_total  + itab_fichier_in-montantd.
          v_totald = v_totald + itab_fichier_in-montantd.
        else.
          v_total  = v_total  - itab_fichier_in-montantc.
          v_totalc = v_totalc + itab_fichier_in-montantc.
        endif.
    *   -= Au changement de poste. =-
        at new poste.
    *     Nouvelle entete
          perform p_entete_piece using itab_fichier_in-societe
                                       itab_fichier_in-poste
                                       v_date.
    *     Initialisation compteur de poste de piece.
          v_count = 1.
        endat.
    *   -= A la fin du poste. =-
        at end of poste.
    *     Modifie l indicateur de dernier poste.
          v_flag_fin = 1.
        endat.
    *   Si c est le dernier poste de la piece on ferme...
        if v_flag_fin = 1.
          if itab_fichier_in-code_dc eq 'D'.
            move 40 to v_clef.
            perform p_fermeture_piece using v_clef
                                            itab_fichier_in-compte
                                            itab_fichier_in-centre
                                            itab_fichier_in-montantd.
          else.
            move 50 to v_clef.
            perform p_fermeture_piece using v_clef
                                            itab_fichier_in-compte
                                            itab_fichier_in-centre
                                            itab_fichier_in-montantc.
          endif.
    *     Gestion de l indicateur de fin de piece.
          move 0 to v_flag_fin.
    *     Gestion de la table des pieces pour l edition.
          move : itab_fichier_in-poste  to itab_piece-typepiece ,
                 v_totalc               to itab_piece-montantc ,
                 v_totald               to itab_piece-montantd .
          append itab_piece.
          clear : v_totalc, v_totald, itab_piece.
    *   Cas normal d un poste de la piece.
        else.
    *     Recherche de la clef.
          if itab_fichier_in-code_dc eq 'D'.
            move 40 to v_clef.
            perform p_poste_piece using itab_fichier_in-societe
                                        v_clef
                                        itab_fichier_in-compte
                                        itab_fichier_in-centre
                                        itab_fichier_in-montantd
                                        v_date.
          else.
            move 50 to v_clef.
            perform p_poste_piece using itab_fichier_in-societe
                                        v_clef
                                        itab_fichier_in-compte
                                        itab_fichier_in-centre
                                        itab_fichier_in-montantc
                                        v_date.
          endif.
        endif.
    *   -= Poste de piece. =-
    *   Si plus de 900 postes dans la piece on equilibre et on contre-passe
    *   dans une nouvelle piece.
        if v_count gt 900.
    *     Recherche de la clef pour l'equilibrage (inverse de la normal).
          if v_total gt 0.
            move 50 to v_clef.
            v_montant = v_total.
          elseif v_total lt 0.
            move 40 to v_clef.
            v_montant = 0 - v_total.
          endif.
    *     Equilibrage.
          perform p_fermeture_piece using v_clef
                                          '2122010900'
                                          v_montant.
    *     Nouvelle entete de piece.
          perform p_entete_piece using itab_fichier_in-societe
                                       itab_fichier_in-poste
                                       v_date.
    *     Initialization de la variable de poste de piece.
          v_count = 1.
    *     Recherche de la clef pour la contre-partie.
          if v_total gt 0.
            move 40 to v_clef.
            v_montant = v_total.
          elseif v_total lt 0.
            move 50 to v_clef.
            v_montant = 0 - v_total.
          endif.
    *     Contre-partie.
          perform p_poste_piece using itab_fichier_in-societe
                                      v_clef
                                      '2122010900'
                                      v_montant
                                      v_date.
    *     Gestion de la table des pieces pour l edition.
          move : itab_fichier_in-poste  to itab_piece-typepiece ,
                 v_totalc               to itab_piece-montantc ,
                 v_totald               to itab_piece-montantd .
          append itab_piece.
          clear : v_totalc, v_totald, itab_piece.
        endif.                  " Supperieur 900 lignes.
      endloop.
    endform.                               " P_CREATION_BATCH
    *   Procédure P_LAST_DAY_OF_MONTH.                                     *
    *   Calcul du dernier jour du mois.                                    *
    form p_last_day_of_month using    i_datum
                             changing e_tt.
      data: datmm   type i ,
            datjj   type i ,
            year(4) type n ,
            date(8) type n ,
            rest    type i ,
            zw_tt   type i .
    * Initialization
      clear e_tt.
    * Recherche du mois.
      datmm = i_datum+2(2).
    * Nombre de jour par mois.
      case datmm.
        when 1.  zw_tt = 31.
        when 2.  zw_tt = 28.
        when 3.  zw_tt = 31.
        when 4.  zw_tt = 30.
        when 5.  zw_tt = 31.
        when 6.  zw_tt = 30.
        when 7.  zw_tt = 31.
        when 8.  zw_tt = 31.
        when 9.  zw_tt = 30.
        when 10. zw_tt = 31.
        when 11. zw_tt = 30.
        when 12. zw_tt = 31.
      endcase.
    * Cas particulier du mois de fevrier.
      if datmm = 2.
        move : '20'          to year(2) ,
                i_datum+0(2) to year+2(2) .
        datjj = year.
        rest  = datjj mod 4.
        if rest = 0.
          zw_tt = 29.
        endif.
      endif.
      move : '20'         to date+4(2) ,
             i_datum+0(2) to date+6(2) ,
             i_datum+2(2) to date+2(2) ,
             zw_tt        to date+0(2) .
      e_tt = date.
    endform.
    *   Procédure P_ENTETE_PIECE.                                          *
    *   Regles :                                                           *
    *            Si le poste est PR alors le type de piece est AC, sinon   *
    *            il est SA.                                                *
    form p_entete_piece using v_bukrs
                              poste
                              v_date.
    * Lancement ecran en-tete de piece.
      perform bdc_dynpro using 'SAPMF05A' '0100'.
    * Validation.
      perform bdc_field using 'BDC_OKCODE' '/00'.
    * Date de piece.
      perform bdc_field using 'BKPF-BLDAT' v_date.
    * Date comptable.
      perform bdc_field using 'BKPF-BUDAT' v_date.
    * Type de piece.
      if poste eq 'PR'.
        perform bdc_field using 'BKPF-BLART' 'AC'.
      else.
        perform bdc_field using 'BKPF-BLART' 'SA'.
      endif.
    * Société.
      perform bdc_field using 'BKPF-BUKRS' v_bukrs.
    * Devise.
      perform bdc_field using 'BKPF-WAERS' p_waers.
    endform.
    *   Procédure P_POSTE_PIECE.                                           *
    *   En fonction de la marque de decimale choisi par l'utilisateur      *
    *   on passe les ',' en '.'  ou inversement.                           *
    form p_poste_piece using v_bukrs
                             v_clef
                             v_compte
                             v_centre
                             v_total
                             v_date.
      data : v_data(25) type c ,           " data temporaire pour valeurs
             v_text like bseg-sgtxt ,      " Texte du poste de la piece
             v_fdlev like skb1-fdlev.      " Niveau trésorerie
    * Vérifie que le compte est traité en trésorerie.
      select single fdlev
             into v_fdlev
             from skb1
             where bukrs eq v_bukrs
             and   saknr eq v_compte.
    * Gestion de la zone texte de poste de la piece.
      move : v_compte to v_text ,
             '/'      to v_text+10 ,
             v_centre to v_text+11 ,
             '/'      to v_text+19 ,
             text-001 to v_text+22 .
    * Gestion zone P -> C
      move v_total to v_data.
      shift v_data left deleting leading space.
    * Test la constante utilisateur marquant la decimale.
      if v_decimal eq 'X'.
        replace ',' with '.' into v_data.
      else.
        replace '.' with ',' into v_data.
      endif.
    * Test s il sagit du premier poste de la piece.
      if v_count eq 1.
    *   Clé de comptabilisation.
        perform bdc_field using 'RF05A-NEWBS' v_clef.
    *   Compte comptable.
        perform bdc_field using 'RF05A-NEWKO' v_compte.
      else.
        perform bdc_dynpro using 'SAPMF05A' '0300'.
        perform bdc_field using 'BDC_OKCODE' '/00'.
    *   Clé de comptabilisation.
        perform bdc_field using 'RF05A-NEWBS' v_clef.
    *   Compte comptable.
        perform bdc_field using 'RF05A-NEWKO' v_compte.
    *   Inconnu ...
        perform bdc_field using 'BDC_SUBSCR' 'SAPLKACB'.
    *   Indique de ne pas repasser sur la saisie des centres de couts ...
        perform bdc_field using 'DKACB-FMORE' ' '.
      endif.
    * Lancement ecran poste de piece.
      perform bdc_dynpro using 'SAPMF05A' '0300'.
    * Validation.
      perform bdc_field using 'BDC_OKCODE' '/00'.
    * Si compte gestion tresorerie alors on positionne la date.
      if v_fdlev ne space.
        perform bdc_field using 'BSEG-VALUT' v_date.
      endif.
    * Montant.
      perform bdc_field using 'BSEG-WRBTR' v_data.
    * Texte du poste de la piece.
      perform bdc_field using 'BSEG-SGTXT' v_text.
    * Inconnu ...
      perform bdc_field using 'BDC_SUBSCR' 'SAPLKACB'.
    * Si le centre de couts est vide on ne traite pas l ecran
    * de saisie du centre de couts.
      if v_centre ne space.
    *   Indique de passer sur le dynpro de saisie centre de couts ...
        perform bdc_field using 'DKACB-FMORE' 'X'.
    *   Ecran de saisie des centres de couts.
    *   Saisie des données du poste de la piéce.
        perform bdc_dynpro using 'SAPLKACB' '0002'.
        perform bdc_field using 'BDC_OKCODE' '/EENTE'.
    *   Centre de coûts.
        perform bdc_field using 'COBL-KOSTL' v_centre.
    *   Encore un inconnu ...
        perform bdc_field using 'BDC_SUBSCR' 'SAPLKACB'.
      else.
    *   Indique de passer sur le dynpro de saisie centre de couts ...
        perform bdc_field using 'DKACB-FMORE' ' '.
      endif.
    endform.
    *   Procédure P_FERMETURE_PIECE.                                       *
    form p_fermeture_piece using v_clef
                                 v_compte
                                 v_centre
                                 v_total.
      data : v_data(25) type c ,           " data temporaire pour valeurs
             v_text like bseg-sgtxt.
    * Gestion de la zone texte de poste de la piece.
      move : v_compte to v_text ,
             '/'      to v_text+10 ,
             v_centre to v_text+11 ,
             '/'      to v_text+19 ,
             text-001 to v_text+22 .
    * Gestion zone P -> C
      move v_total to v_data.
      shift v_data left deleting leading space.
    * Test la constante utilisateur marquant la decimale.
      if v_decimal eq 'X'.
        replace ',' with '.' into v_data.
      else.
        replace '.' with ',' into v_data.
      endif.
      perform bdc_dynpro using 'SAPMF05A' '0300'.
      perform bdc_field using 'BDC_OKCODE' '/00'.
    * Clé de comptabilisation.
      perform bdc_field using 'RF05A-NEWBS' v_clef.
    * Compte comptable.
      perform bdc_field using 'RF05A-NEWKO' v_compte.
    * Inconnu ...
      perform bdc_field using 'BDC_SUBSCR' 'SAPLKACB'.
    * Indique de ne pas repasser sur la saisie des centres de couts ...
      perform bdc_field using 'DKACB-FMORE' ' '.
      perform bdc_dynpro using 'SAPMF05A' '0300'.
      perform bdc_field using 'BDC_OKCODE' '=BU'.
    * Montant.
      perform bdc_field using 'BSEG-WRBTR' v_data.
    * Texte du poste de la piece.
      perform bdc_field using 'BSEG-SGTXT' v_text.
    * Inconnu ...
      perform bdc_field using 'BDC_SUBSCR' 'SAPLKACB'.
      if v_centre ne space.
    *   Indique de passer sur la saisie des centres de couts ...
        perform bdc_field using 'DKACB-FMORE' 'X'.
    *   Ecran de saisie des centres de couts.
    *   Saisie des données du poste de la piéce.
        perform bdc_dynpro using 'SAPLKACB' '0002'.
        perform bdc_field using 'BDC_OKCODE' '/EENTE'.
    *   Centre de coûts.
        perform bdc_field using 'COBL-KOSTL' v_centre.
    *   Encore un inconnu ...
        perform bdc_field using 'BDC_SUBSCR' 'SAPLKACB'.
      else.
    *   Indique de ne pas repasser sur la saisie des centres de couts ...
        perform bdc_field using 'DKACB-FMORE' ' '.
      endif.
    * Transfert du dossier.
      perform insert_bdc using v_t_code.
      refresh bdc_tab.
      clear bdc_tab.
    endform.
    *   Form OPEN_BDC                                                      *
    *   Ouverture du dossier Batch-Input.                                  *
    form open_bdc using v_nom_dossier.
      call function 'BDC_OPEN_GROUP'
           exporting
                client              = sy-mandt          " Numéro de mandant
                group               = v_nom_dossier     " Nom dossier batch
                keep                = 'X'               " Code
                user                = sy-uname          " Nom utilisateur
           exceptions
                client_invalid      = 1
                destination_invalid = 2
                group_invalid       = 3
                group_is_locked     = 4
                holddate_invalid    = 5
                internal_error      = 6
                queue_error         = 7
                running             = 8
                system_lock_error   = 9
                user_invalid        = 10
                others              = 11.
      if sy-subrc ne 0.
        write : /1 text-001 ,
                /1 'Erreur :' , sy-subrc.
      endif.
      refresh bdc_tab.
      clear   bdc_tab.
      exit.
    endform.                       " OPEN_BDC
    *   Form CLOSE_BDC                                                     *
    *   Fermeture du dossier BTCI                                          *
    form close_bdc.
      call function 'BDC_CLOSE_GROUP'
           exceptions
                not_open    = 1
                queue_error = 2
                others      = 3.
      if sy-subrc ne 0.
        write : /1 text-002 ,
                /1 'Erreur :' , sy-subrc.
      endif.
    endform.                     " CLOSE_BDC
    *   Form BDC_DYNPRO                                                    *
    *   Alimentation de la ligne d'entête de BDCTAB                        *
    form bdc_dynpro using value(progname)
                          value(dynpronr).
    * Efface la header-line.
      clear bdc_tab.
    * Insertion des valeurs.
      bdc_tab-program  = progname.
      bdc_tab-dynpro   = dynpronr.
      bdc_tab-dynbegin = 'X'.
    * Enregistrement des valeurs.
      append bdc_tab.
    endform.                    " BDC_DYNPRO
    *   Form BDC_FIELD                                                     *
    *   Traitement des enregistrements de la structure BDCTAB              *
    *      --> FIELDNAME  Nom du champ                                     *
    *      --> FIELDVALUE Valeur du champ                                  *
    form bdc_field using value(fieldname) value(fieldvalue).
    * Efface la header-line.
      clear bdc_tab.
    * Insertion des valeurs.
      bdc_tab-fnam = fieldname.
      bdc_tab-fval = fieldvalue.
    * Enregistrement des valeurs.
      append bdc_tab.
    endform.                " BDC_FIELD
    * Form BDC_CURSOR                                                      *
    * Positionnement du curseur sur un champ particulier                   *
    form bdc_cursor using value(fieldname) value(fieldvalue).
    * Efface la header-line.
      clear bdc_tab.
    * Insertion des valeurs.
      bdc_tab-fnam = fieldname.
      bdc_tab-fval = fieldvalue.
    * Enregistrement des valeurs.
      append bdc_tab.
    endform.              " BDC_CURSOR
    *   Form  INSERT_BDC                                                   *
    *   Insertion dans le dossier BTCI                                     *
    *   Attention : la transaction est codée en dur                        *
    form insert_bdc using t_code.
      call function 'BDC_INSERT'
           exporting
                tcode            = t_code
           tables
                dynprotab        = bdc_tab
           exceptions
                internal_error   = 1
                not_open         = 2
                queue_error      = 3
                tcode_invalid    = 4
                printing_invalid = 5
                posting_invalid  = 6
                others           = 7.
      if sy-subrc ne 0.
        write : /1 text-003 ,
                /1 'Erreur :' , sy-subrc.
      endif.
    endform.                  " INSERT_BDC
    *   Procédure P_DECIMAL.                                               *
    form p_decimal.
    * Recherche de la constante utilisateur sur la virgule decimale.
      select single dcpfm
             into v_decimal
             from usr01
             where bname eq sy-uname.
    endform.
    *   Procédure P_EDITION.                                               *
    *   Procédure d'edition du resultat de la génération du dossier        *
    *   Batch-Input.                                                       *
    form p_edition.
      data : v_solde(13) type p decimals 2.
      skip 1.
      write : /1 'Comptabilisation de la paie venant de Pléïades.'.
    * Le mois.
      skip 2.
      case v_periode+2(2).
        when 01.
          write : /1 'Mois : Janvier'.
        when 02.
          write : /1 'Mois : Fevrier'.
        when 03.
          write : /1 'Mois : Mars'.
        when 04.
          write : /1 'Mois : Avril'.
        when 05.
          write : /1 'Mois : Mai'.
        when 06.
          write : /1 'Mois : Juin'.
        when 07.
          write : /1 'Mois : Juillet'.
        when 08.
          write : /1 'Mois : Aout'.
        when 09.
          write : /1 'Mois : Septembre'.
        when 10.
          write : /1 'Mois : Octobre'.
        when 11.
          write : /1 'Mois : Novembre'.
        when 12.
          write : /1 'Mois : Decembre'.
      endcase.
    * La date comptable.
      skip 1.
      write : /1  'Date comptable :' ,
               18 v_date+0(2) ,
               20 '/' ,
               21 v_date+2(2) ,
               23 '/' ,
               24 v_date+4(4).
    * Piece SA.
      skip 2.
      write : /1  'Piece(s) SA :' ,
              /10 'Montant Debit' ,
               40 'Montant Credit' ,
               70 'Solde'.
      loop at itab_piece where typepiece ne 'PR'.
        v_solde = itab_piece-montantd - itab_piece-montantc.
        write : /1  itab_piece-montantd ,
                 31 itab_piece-montantc ,
                 61 v_solde.
      endloop.
    * Piece AC.
      skip 2.
      write : /1  'Piece(s) AC :' ,
              /10 'Montant Debit' ,
               40 'Montant Credit' ,
               70 'Solde'.
      loop at itab_piece where typepiece eq 'PR'.
        v_solde = itab_piece-montantd - itab_piece-montantc.
        write : /1  itab_piece-montantd ,
                 31 itab_piece-montantc ,
                 61 v_solde.
      endloop.
      skip 4.
      write : /1 'Anomalie :' ,
              /1 'Nombre de lignes dont le montant est nul :' ,
                 v_nb_blanc no-zero.
    endform.

  • LSMW Recording Help

    When we run the transaction FB01 for Customer Document DA, the whole transaction goes smooth without asking for any CO object like profit center and gets saved.  But when we do LSMW recording of the same transaction code FB01 and every information same, when we are done with entering the second line item (Posting Key 50 - G/L migration acct 111111), and amount,  a window pops up asking for a profit center. THough it is not a Cost element, why are we getting prompted to enter a profit center. THis only pops up when doing LSMW recording. Ither wise when we are running this transaction , it does not ask for a profit center. Please help. It is very urgent. we are doing the LSMW recording for migrating customer open balances.
    Thnxs
    Lakshmi

    Alex,
    The name of file for Converted data is a system generated combination of your Project subproject and object followed by lsmw.conv  as   Project_Subproject_Object.lsmw.conv
    System has set a limit of a maximum of 45 characters. It the file name exceeds 45 characters, the system will throw the error.
    Just rename the file such that it is with in the 45 charcter limit....you will be fine
    Hope this helps
    Vinodh Balakrishnan

  • Post Document in FB01

    Hi Experts,
    I am using below mentioned FM to post the document in FB01 and working fine when i am going for call transaction.
    POSTING_INTERFACE_START
    POSTING_INTERFACE_DOCUMENT
    POSTING_INTERFACE_END
    My requirement is i want to use the same FM to post the document in FB01 with batch input session method.
    -Rajneesh Gupta

    Hi Rajneesh ,
    I also have the similar requirement if you have the solution please help with code as I have to record bdc for fb01 and post account document
    Moderator Message: Please continue with your own post - BDC for FB01.
    Message was edited by: Suhas Saha

  • Posting Documents in FB01

    Can any one help me in posting documents in FB01...
    i am using session method  only..
    Please help me

    hi,
    i prefer to use 'BAPI_ACC_DOCUMENT_POST' for creatin a financial document i try to give to u how to set the minimum value in the structure/tables of the bapi.
    > DOCUMENTHEADER                                                        
    >        BUS_ACT                    =    'RFBU'           "for FI document    
    >        USERNAME                =    sy-uname
    >        HEADER_TXT              =    your text
    >        COMP_CODE              =    Company code
    >        DOC_DATE                  =    Document date
    >        PSTNG_DATE              =    Posting date
    >        FISC_YEAR(1)              =    The year of posting date
    >        FIS_PERIOD(1)             =    the period of posting date
    >        DOC_TYPE                  =    document type
    if you set a different year or period from the value that you have in the posting date the bapi trigger an error
    > ACCOUNT GL
    >       ITEMNO_ACC   = progessive number
    >       GL_ACCOUNT  = G/L Account
    >       ITEM_TEXT       = item text
    >       DOC_TYPE      = document type (the same of the header for all item)
    >       COMP_CODE   = company code (the same of the header for all item)
    >       BUS_AREA      = business area
    >       TAX_CODE       = tax code
    if you set a different doc_type or company code for each item the bapi trigger an error
    > ACCOUNTTAX                
    >            ITEMNO_ACC   =  progressive number
    >            GL_ACCOUNT   = G/L Account referred to TAX CODE
    >            TAX_CODE        = TAX CODE
    >            TAX_RATE        =  TAX RATE
    >            ITEMNO_TAX     = progressive number  which tax item is referred
    >CURRENCYAMOUNT
    >           ITEMNO_ACC     =  progressive number
    >           CURRENCY        =  currency
    >           CURRENCY_ISO =  iso currency that you find in TCURC-ISOCD table
    >           AMT_DOCCUR    =  amount with sign the sign +/- identify Debit/Credit Indicator
    > - this field only for tax record
    >           AMT_BASE        =   is the AMT_DOCCUR of the line which ypu want to calculate the tax with sign
    >           TAX_AMT           =    tax amount
    usually for calculate the correct value i use these functions 'CALCULATE_TAX_FROM_GROSSAMOUNT'.
    for example:
    DOCUMENTHEADER                                  
    >        BUS_ACT                    =    'RFBU'
    >        USERNAME                =    sy-uname
    >        HEADER_TXT              =    'my_text'
    >        COMP_CODE              =    '0001'
    >        DOC_DATE                  =    '20080115'
    >        PSTNG_DATE              =    '20080115'
    >        FISC_YEAR(1)              =    '2008'
    >        FIS_PERIOD(1)             =    '01'
    >        DOC_TYPE                  =    'SA'
    ACCOUNT GL
    >Record 1
    >ITEMNO_ACC =  0000000001
    >GL_ACCOUNT =   0290111010
    >ITEM_TEXT =   ITEM_TEXT
    >DOC_TYPE =    SA
    >COMP_CODE =    0001
    >BUS_AREA =   GS1                                                                       
    >Record 2
    >ITEMNO_ACC =  0000000002
    >GL_ACCOUNT =    0500103900
    >ITEM_TEXT =   ITEM_TEXT
    >DOC_TYPE =   SA
    >COMP_CODE =   0001
    >TAX_CODE =  V2
    ACCOUNTTAX
    > Record 3
    >ITEMNO_ACC =   0000000003
    >GL_ACCOUNT =  0221103001
    >TAX_CODE =  V2
    >TAX_RATE =  20.000
    >ITEMNO_TAX = 0000000002
    CURRENCYAMOUNT
    >Record 1
    >ITEMNO_ACC = 0000000001
    >CURRENCY =  EUR
    >CURRENCY_ISO =   EUR
    >AMT_DOCCUR  = 150.00
    >AMT_BASE =  0.00
    >TAX_AMT =  0.00
    >Record 2
    >ITEMNO_ACC = 0000000002
    >CURRENCY =  EUR
    >CURRENCY_ISO =   EUR
    >AMT_DOCCUR  = -125.00
    >AMT_BASE =  0.00
    >TAX_AMT =  0.00
    >Record 3
    >ITEMNO_ACC = 0000000003
    >CURRENCY =  EUR
    >CURRENCY_ISO =   EUR
    >AMT_DOCCUR =  -25.00
    >AMT_BASE =  -125.00
    >TAX_AMT =   -25.00
    hope that is useful.
    Bye
    Marco

  • Please help in finding the bug in this BDC for FB01

    Please find the bug in the following BDC for FB01 of mine. It picks up the entries from the very first record of the excel file, every time.
    report ZFI_BDC
           no standard page heading line-size 255.
    data: bdcdata1 like bdcdata occurs 0 with header line.
    data : vf_index type i.
    DATA: BEGIN OF ENTRIES occurs 0,
            BLDAT(8),
            BUKRS(4),
            BLART(2),
            WAERS(5),
            BUDAT(8),
            RECNO(5),
            NEWBS(2),
            NEWKO(17),
            NEWNUM(1),
            WRBTR(13),
            GSBER(4),
            SECCO(4),
            zuonr(18),
            SGTXT(50),
            NEWBS_2(2),
            NEWKO_2(17),
            NEWNUM_2(1),
            WRBTR_2(13),
            GSBER_2(4),
            SECCO_2(4),
            zuonr_2(18),
            SGTXT_2(50),
            no type i,
    END OF ENTRIES.
    DATA: BEGIN OF ENTRIES2 OCCURS 0 ,
            BLDAT(8),
            BUKRS(4),
            BLART(2),
            WAERS(5),
            BUDAT(8),
            RECNO(5),
            NEWBS(2),
            NEWKO(17),
            NEWNUM(1),
            WRBTR(13),
            GSBER(4),
            SECCO(4),
            zuonr(18),
            SGTXT(50),
            NEWBS_2(2),
            NEWKO_2(17),
            NEWNUM_2(1),
            WRBTR_2(13),
            GSBER_2(4),
            SECCO_2(4),
            zuonr_2(18),
            SGTXT_2(50),
            no type i,
    END OF ENTRIES2.
    DATA: TEMP(8),
          DOCDATE(8),
          SPLGL(1),
          PKEY(2),
          GL(17),
          VCHAMT(13),
          BUSAREA(4),
          SECCODE(4),
          zzuonr(18),
          COSTCEN(10),
          AUFNR(3),
          SGTXT(50),
          item(50)           TYPE c,
          DS TYPE I,
          DS2 TYPE I.
    data : vf_start_col type i value '1',      "start column
           vf_start_row type i value '1',      "start row
           vf_end_col   type i value '256',    "maximum column
           vf_end_row   type i value '65536',  "maximum row
           p_text(20).                         "stores error messages
    Internal Table
    data : it_excel type  kcde_cells occurs 0 with header line.
    */ Field symbol
    field-symbols : <fs>.
    parameters: p_file   LIKE rlgrap-filename MEMORY ID M01,
                NOHEADER AS CHECKBOX.
    parameters: COMPANY(4) TYPE C DEFAULT 'SCL',
                GROUP(12) TYPE C DEFAULT 'BDCTEST',
                USER(12) TYPE C DEFAULT SY-UNAME,
                KEEP(1) TYPE C DEFAULT 'X',
                POSTDATE LIKE SY-DATUM DEFAULT SY-DATUM,
                DOC_TYPE(2) TYPE C DEFAULT 'SA',
                HOLDDATE LIKE SY-DATUM.
    ***********************************************upload data from excel
    CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
      EXPORTING
        filename                      = p_file
        i_begin_col                   = VF_START_COL
        i_begin_row                   = VF_START_ROW
        i_end_col                     = VF_END_COL
        i_end_row                     = VF_END_ROW
      tables
        intern                        = IT_EXCEL
    EXCEPTIONS
       INCONSISTENT_PARAMETERS       = 1
       UPLOAD_OLE                    = 2
       OTHERS                        = 3 .
    IF sy-subrc <> 0.
              WRITE: / 'EXCEL UPLOAD FAILED :', p_file, SY-SUBRC.
    else.
      sort it_excel by row col.
          loop at it_excel.
         IF NOHEADER = 'X'
        AND It_EXCEL-row = 1.
          CONTINUE.
        ENDIF.
         vf_index = it_excel-col.
       assign component vf_index of structure ENTRIES to <fs>.
            move  it_excel-value to <fs>.
          at end of row.
            append ENTRIES.
            clear ENTRIES.
          endat.
          endloop.
      endif.
    start-of-selection.
    DS = 1.
    LOOP AT ENTRIES.
    ENTRIES-NO = DS.
    MODIFY ENTRIES.
    DS = DS + 1.
    *ON CHANGE OF ENTRIES-zuonr.
    *DS = 1.
    *ENTRIES-NO = DS.
    *MODIFY ENTRIES.
    *DS = DS + 1.
    *ENDON.
    ENDLOOP.
    LOOP AT ENTRIES where no = 1.
        MOVE-CORRESPONDING  ENTRIES TO ENTRIES2.
    APPEND ENTRIES2.
    CLEAR ENTRIES2.
      ENDLOOP.
    DS2 = 1.
    LOOP AT ENTRIES2.
    ENTRIES2-NO = DS2.
    MODIFY ENTRIES2.
    DS2 = DS2 + 1.
    *ON CHANGE OF ENTRIES2-zuonr.
    *DS2 = 1.
    *ENTRIES2-NO = DS2.
    *MODIFY ENTRIES2.
    *DS2 = DS2 + 1.
    *ENDON.
    ENDLOOP.
    LOOP AT ENTRIES.
    REFRESH BDCDATA1.
      WRITE: /  ENTRIES-RECNO,
                ENTRIES-NEWBS,
                ENTRIES-NEWKO,
                ENTRIES-NEWNUM,
                ENTRIES-WRBTR,
                ENTRIES-GSBER,
                ENTRIES-SECCO,
                ENTRIES-ZUONR,
                ENTRIES-SGTXT.
    ENDLOOP.
    WRITE: / 'THIS IS THE BDC PROGRAM FOR SAMTEL'.
    TEMP = POSTDATE.
    DOCDATE = TEMP+6(2).
    DOCDATE2(2) = TEMP4(2).
    DOCDATE4(4) = TEMP0(4).
    *delete ENTRIES where no = 1.
    delete ENTRIES2 where no = 2.
    clear ENTRIES.
    clear ENTRIES2.
    LOOP AT ENTRIES .
    if ENTRIES-no = 2.
    perform bdc_dynpro      using 'SAPMF05A' '0100'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RF05A-NEWKO'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BKPF-BLDAT'            "DOCDATE.
                                   ENTRIES-BLDAT.
    perform bdc_field       using 'BKPF-BLART'            "DOC_TYPE.
                                   ENTRIES-BLART.
    perform bdc_field       using 'BKPF-BUKRS'            "COMPANY.
                                   ENTRIES-BUKRS.
    perform bdc_field       using 'BKPF-BUDAT'            "DOCDATE.
                                   ENTRIES-BUDAT.
    perform bdc_field       using 'BKPF-WAERS'            "INR'.
                                   ENTRIES-WAERS.
    perform bdc_field       using 'RF05A-NEWBS'
                                  ENTRIES-NEWBS.
    perform bdc_field       using 'RF05A-NEWKO'
                                  ENTRIES-NEWKO.
    perform bdc_dynpro      using 'SAPMF05A' '0300'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'BSEG-SGTXT'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BSEG-WRBTR'
                                  ENTRIES-WRBTR.
    perform bdc_field       using 'BSEG-SGTXT'
                                  ENTRIES-SGTXT.
    perform bdc_dynpro      using 'SAPLKACB' '0002'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'COBL-GSBER'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTE'.
    perform bdc_field       using 'COBL-GSBER'
                                  ENTRIES-GSBER.
    perform bdc_dynpro      using 'SAPMF05A' '0300'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RF05A-NEWKO'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BSEG-WRBTR'
                                  ENTRIES-WRBTR.
    perform bdc_field       using 'BSEG-SGTXT'
                                  ENTRIES-SGTXT.
    perform bdc_field       using 'RF05A-NEWBS'
                                  ENTRIES-NEWBS.
    perform bdc_field       using 'RF05A-NEWKO'
                                  ENTRIES-NEWKO.
    perform bdc_dynpro      using 'SAPLKACB' '0002'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'COBL-GSBER'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTE'.
    perform bdc_field       using 'COBL-GSBER'
                                  ENTRIES-GSBER.
    perform bdc_dynpro      using 'SAPMF05A' '0301'.
    *perform bdc_field       using 'BDC_CURSOR'
                                 'BSEG-SGTXT_2'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BSEG-WRBTR'
                                  ENTRIES-WRBTR_2.
    perform bdc_field       using 'BSEG-GSBER'
                                  ENTRIES-GSBER_2.
    perform bdc_field       using 'BSEG-SGTXT'
                                  ENTRIES-SGTXT_2.
    perform bdc_dynpro      using 'SAPMF05A' '0301'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'BSEG-WRBTR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=BU'.
    perform bdc_field       using 'BSEG-WRBTR'
                                  ENTRIES-WRBTR_2.
    perform bdc_field       using 'BSEG-GSBER'
                                  ENTRIES-GSBER_2.
    perform bdc_field       using 'BSEG-SGTXT'
                                  ENTRIES-SGTXT_2.
    call transaction 'F-02' using bdcdata1 mode 'A'.
    else.
    perform bdc_dynpro      using 'SAPMF05A' '0100'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RF05A-NEWKO'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BKPF-BLDAT'            "DOCDATE.
                                   ENTRIES-BLDAT.
    perform bdc_field       using 'BKPF-BLART'            "DOC_TYPE.
                                   ENTRIES-BLART.
    perform bdc_field       using 'BKPF-BUKRS'            "COMPANY.
                                   ENTRIES-BUKRS.
    perform bdc_field       using 'BKPF-BUDAT'            "DOCDATE.
                                   ENTRIES-BUDAT.
    perform bdc_field       using 'BKPF-WAERS'            "INR'.
                                   ENTRIES-WAERS.
    perform bdc_field       using 'RF05A-NEWBS'
                                  ENTRIES-NEWBS.
    perform bdc_field       using 'RF05A-NEWKO'
                                  ENTRIES-NEWKO.
    perform bdc_dynpro      using 'SAPMF05A' '0300'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'BSEG-SGTXT'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BSEG-WRBTR'
                                  ENTRIES-WRBTR.
    perform bdc_field       using 'BSEG-SGTXT'
                                  ENTRIES-SGTXT.
    perform bdc_dynpro      using 'SAPLKACB' '0002'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'COBL-GSBER'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTE'.
    perform bdc_field       using 'COBL-GSBER'
                                  ENTRIES-GSBER.
    perform bdc_dynpro      using 'SAPMF05A' '0300'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RF05A-NEWKO'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BSEG-WRBTR'
                                  ENTRIES-WRBTR.
    perform bdc_field       using 'BSEG-SGTXT'
                                  ENTRIES-SGTXT.
    perform bdc_field       using 'RF05A-NEWBS'
                                  ENTRIES-NEWBS_2.
    perform bdc_field       using 'RF05A-NEWKO'
                                  ENTRIES-NEWKO_2.
    perform bdc_dynpro      using 'SAPLKACB' '0002'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'COBL-GSBER'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTE'.
    perform bdc_field       using 'COBL-GSBER'
                                  ENTRIES-GSBER_2.
    perform bdc_dynpro      using 'SAPMF05A' '0301'.
    **perform bdc_field       using 'BDC_CURSOR'
                                 'BSEG-SGTXT_2'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BSEG-WRBTR'
                                  ENTRIES-WRBTR_2.
    perform bdc_field       using 'BSEG-GSBER'
                                  ENTRIES-GSBER_2.
    perform bdc_field       using 'BSEG-SGTXT'
                                  ENTRIES-SGTXT_2.
    perform bdc_dynpro      using 'SAPMF05A' '0301'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'BSEG-WRBTR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=BU'.
    perform bdc_field       using 'BSEG-WRBTR'
                                  ENTRIES-WRBTR_2.
    perform bdc_field       using 'BSEG-GSBER'
                                  ENTRIES-GSBER_2.
    perform bdc_field       using 'BSEG-SGTXT'
                                  ENTRIES-SGTXT_2.
    call transaction 'F-02' using bdcdata1 mode 'A'.
    endif.
    ENDLOOP.
    clear entries.
    refresh entries.
           Start new screen                                              *
    form bdc_dynpro using program dynpro.
       clear bdcdata1.
      bdcdata1-program  = program.
      bdcdata1-dynpro   = dynpro.
      bdcdata1-dynbegin = 'X'.
    append bdcdata1.
    endform.
           Insert field                                                  *
    form bdc_field using fnam fval.
       clear bdcdata1.
        bdcdata1-fnam = fnam.
        bdcdata1-fval = fval.
    append bdcdata1.
    endform.

    Alok,
    1) Write upload data from excel in Start of selection
    2) I could not find any need for table entries2 in the logic.
    3) I feel the data mapping from the uploaded file is wrong. Can you look into http://www.sapdevelopment.co.uk/file/file_upexcelalt1.htm for the proper usage. Actually, this logic will work. Similar way you can map the data to your internal table <b>entries</b>
    4) BDC part I feel its ok.
    Let me know if you have still error after these steps.
    Rgds,
    TM

  • Issue in LSMW(Direct Input) for FB01 with (RFBIBL00)

    Hi All,
    I am developing a LSMW-Direct input method for TCode-FB01 using program RFBIBL00.
    I am using one file as input file. I have below fields in the file.
    STYPE
    BLART
    BUKRS
    BLDAT
    BUDAT
    MONAT
    WAERS
    KURSF
    XBLNR
    BKTXT
    XMWST
    NEWBS
    NEWKO
    NEWUM
    WRBTR
    KOSTL
    PROJK
    AUFNR
    PRCTR
    SEGMEN
    MWSKZ
    WMWST
    ZFBDT
    ZUONR
    SGTXT
    My Data is as below: (Single record) 1 - Header data, 2-Item data
    1     SA     1123     01062009     01062009     6     USD          Test1     Testing
    2                                                       40     100005          10                                             Test     Test
    2                                                       50     100005          10                                             Test     Test
    After 'Converted data' step it is displaying 7 rows instead of 3 rows for BGR00, BBKPF, BBSEG.
    Is there any condition(logic) i need to write to make it to 3 rows.
    All the data displayed above is for single record.
    Because of this issue i am not able to create document through FB01.
    How to solve this issue!
    Thanks,
    Deep.

    you need to pass 2 strctures like below
    1 is header and 1 is item    
    here  INDENT  is link between 2 files
    in your case  1 record: BGR00,
    1 record :  BBKPF
    2 records:  BBSEG
    its only 4 records,  i think you file contains space for 3 more record you check that.
    and also in the last step you have option  for creating the batch input method, create BI and run in foreground ....
    YFIC_HEADER           Header
             INDENT                         C(010)    Identifier
             BLDAT                          C(008)    Document Date
             BLART                          C(002)    Document Type
             BUKRS                          C(004)    Company Code
             BUDAT                          C(008)    Posting Date
             MONAT                          C(002)    Posting Period
             WAERS                          C(005)    Currency
             KURSF                          C(009)    Exchange rate
             BELNR                          C(010)    Document Number
             WWERT                          C(008)    Translation Date
             XBLNR                          C(016)    Reference
             BVORG                          C(016)    Cross-co. code no.
             BKTXT                          C(025)    Document Header Text
             PARGB                          C(004)    Trading part.BA
             XMWST                          C(001)    Calculate Tax
             LDGRP                          C(004)    Ledger Group
             YFIC_ITEM             Item Data
                 INDENT                         C(010)    Identifier
                 NEWBS                          C(002)    Posting Key
                 NEWKO                          C(017)    Account
                 NEWUM                          C(001)    Special G/L ind.
                 NEWBW                          C(003)    Transact. type
                 WRBTR                          C(015)    Amount
                 MWSKZ                          C(002)    Tax Code
                 XSKRL                          C(001)    W/o cash disc.
                 KOSTL                          C(010)    Cost Center
                 AUFNR                          C(012)    Order
                 GSBER                          C(004)    Business Area
                 PRCTR                          C(010)    Profit Center
                 RASSC                          C(006)    Trading Partner
                 FKBER                          C(004)    Functional Area

Maybe you are looking for

  • How to get string from jtextpane along with its attributes

    sir, How to get string from jtextpane along with its attributes i,e font,size,style,color etc. please help me out. my mail id is [email protected]

  • Java.lang.error

    Hi, I have BlackBerry Curve 9220. before I get to sleep last night my BB was okay until when I woke up its already Uncaught exception java.lang.error and many more pops up. The main is plain white and the apps are alined left. can you help me please

  • Oracle Real Application Clusters Guard

    Is that separate install different from RAC install ? Is Cluster Guard is mandatory for Oracle 9i RAC environments ?

  • KNOWLEDGE TRANSFER

    Hi, what is the functionality of 'KNOWLEDGE TRANSFER' in SAP

  • How to make a crop looks like a camera zoom?

    If I crop a part of a video and want to make the crop looks like a camera zoom... is there a "zoom transition" to put before and after the crop part? Million thanks if someone can solve this technical question...