FB60 Upload to Vendor.
MIRO: When the invoice is to be posted from MM side. In this we raise a Purchase Order (PO), Goods are received (MIGO) then we do Invoice Receipt (MIRO). Automatically while posting MIRO the FI document gets generated. For this the settings are to be made in FI-MM integration.
FB60: This is a pure FI transaction for vendor invoice posting. where the client do not want to maintain Material Master or do not want to activate MM. then the invoice could be raised from FI side. In this transaction PO and goods receipt details are not required.
JV Journal Voucher Posting-Journal voucher is prepared for the transactions which does not relate to sales, purchases, cash, bank, material returns.
JV Journal Voucher Posting-Journal voucher is prepared for the transactions which does not relate to sales, purchases, cash, bank, material returns.
G/l to G/l posting
Here we can post almost all type accounting except customer account and vendor account.
Non related to SD(AR) and MM(AP) . Normal G/l Account Posting. example salary posting and provision posting . Document Type is SA
Here we can post almost all type accounting except customer account and vendor account.
Non related to SD(AR) and MM(AP) . Normal G/l Account Posting. example salary posting and provision posting . Document Type is SA
we basically used to pass some adjustment entries in Journal voucher mode such as- Discount given to Debtors, Discount received from Creditor, Bad Debts, Depreciation and so on.
Sales:
When you are raising service invoice like labour is involved not material you can use F-22 or FB70
Account Receivable -> customer to G/L
Account Receivable -> customer to G/L
Purchase :
When you are booking service provider invoice like an AMC charges you can use F-43 or FB60
Account Payable -> Gl to vendor
REPORT zfi_fb60.
TYPES: BEGIN OF ty_out,
accnt TYPE invfo-accnt,
bldat TYPE invfo-bldat,
XBLNR TYPE INVFO-XBLNR,
SGTXT1 TYPE INVFO-SGTXT,
wrbtr TYPE invfo-wrbtr,
zterm TYPE invfo-zterm,
hkont TYPE acgl_item-hkont,
mwskz TYPE acgl_item-mwskz,
sgtxt TYPE acgl_item-sgtxt,
gsber TYPE acgl_item-gsber,
kostl TYPE acgl_item-kostl,
hsn_sac TYPE acgl_item-hsn_sac,
END OF ty_out.
TYPES : BEGIN OF ty_final,
accnt TYPE invfo-accnt,
belnr TYPE bseg-belnr,
END OF ty_final.
DATA lv_wrbtr(16) TYPE c.
DATA p_budat1(10) TYPE c.
DATA p_bldat1(10) TYPE c.
DATA lv_accnt TYPE invfo-accnt.
DATA it_out TYPE TABLE OF ty_out WITH HEADER LINE.
DATA it_final TYPE TABLE OF ty_final WITH HEADER LINE.
DATA: it_bdcdata TYPE TABLE OF bdcdata,
wa_bdcdata TYPE bdcdata,
it_type TYPE truxs_t_text_data,
t_message TYPE TABLE OF bdcmsgcoll WITH HEADER LINE.
DATA it_fieldcat TYPE slis_t_fieldcat_alv.
DATA wa_fieldcat TYPE slis_fieldcat_alv.
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-100.
PARAMETERS : p_bukrs TYPE bkpf-bukrs OBLIGATORY DEFAULT 'TH01',
p_budat TYPE bkpf-budat OBLIGATORY,
p_waers TYPE bkpf-waers OBLIGATORY DEFAULT 'INR',
p_bupla TYPE invfo-bupla OBLIGATORY DEFAULT 'TN01'.
SELECTION-SCREEN END OF BLOCK blk1.
SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME TITLE text-200.
PARAMETER p_file TYPE rlgrap-filename OBLIGATORY.
SELECTION-SCREEN END OF BLOCK blk.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file .
CALL FUNCTION 'F4_FILENAME'
* EXPORTING
* PROGRAM_NAME = SYST-CPROG
* DYNPRO_NUMBER = SYST-DYNNR
* FIELD_NAME = ' '
IMPORTING
file_name = p_file.
START-OF-SELECTION.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_field_seperator = 'X'
i_line_header = 'X'
i_tab_raw_data = it_type
i_filename = p_file
TABLES
i_tab_converted_data = it_out
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
WRITE: p_budat TO p_budat1.
LOOP AT it_out.
CLEAR lv_accnt.
lv_accnt = it_out-accnt.
WRITE: it_out-bldat TO p_bldat1.
PERFORM bdc_dynpro USING 'SAPMF05A' '1100'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=DUMMY'.
PERFORM bdc_field USING 'RF05A-BUSCS'
'R'.
PERFORM bdc_field USING 'BDC_CURSOR'
'INVFO-XMWST'.
PERFORM bdc_field USING 'INVFO-ACCNT'
it_out-accnt.
PERFORM bdc_field USING 'INVFO-BLDAT'
p_bldat1.
PERFORM bdc_field USING 'INVFO-BUDAT'
p_budat1.
PERFORM bdc_field USING 'INVFO-SGTXT'
it_out-sgtxt1.
PERFORM bdc_field USING 'INVFO-XBLNR'
it_out-xblnr.
lv_wrbtr = it_out-wrbtr.
CONDENSE lv_wrbtr.
PERFORM bdc_field USING 'INVFO-WRBTR'
lv_wrbtr.
PERFORM bdc_field USING 'INVFO-WAERS'
p_waers.
PERFORM bdc_field USING 'INVFO-XMWST'
'X'.
PERFORM bdc_field USING 'INVFO-BUPLA'
p_bupla.
PERFORM bdc_dynpro USING 'SAPMF05A' '1100'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=PAYM'.
PERFORM bdc_field USING 'RF05A-BUSCS'
'R'.
PERFORM bdc_field USING 'BDC_CURSOR'
'INVFO-XMWST'.
PERFORM bdc_dynpro USING 'SAPMF05A' '1100'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'INVFO-ZTERM'
it_out-zterm.
PERFORM bdc_field USING 'BDC_CURSOR'
'ACGL_ITEM-HSN_SAC(01)'.
PERFORM bdc_field USING 'ACGL_ITEM-HKONT(01)'
it_out-hkont.
PERFORM bdc_field USING 'ACGL_ITEM-WRBTR(01)'
lv_wrbtr..
PERFORM bdc_field USING 'ACGL_ITEM-MWSKZ(01)'
it_out-mwskz.
PERFORM bdc_field USING 'ACGL_ITEM-SGTXT(01)'
it_out-sgtxt.
PERFORM bdc_field USING 'ACGL_ITEM-GSBER(01)'
it_out-gsber.
PERFORM bdc_field USING 'ACGL_ITEM-KOSTL(01)'
it_out-kostl.
PERFORM bdc_field USING 'ACGL_ITEM-HSN_SAC(01)'
it_out-hsn_sac.
PERFORM bdc_dynpro USING 'SAPMF05A' '1100'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BS'.
CLEAR : t_message, t_message[].
CALL TRANSACTION 'FB60' USING it_bdcdata
MODE 'E' UPDATE 'S' MESSAGES INTO t_message.
READ TABLE t_message WITH KEY msgnr = '312'.
IF sy-subrc = 0.
DATA lv_msg(50) TYPE c.
CLEAR lv_msg.
CONCATENATE 'Document Created' t_message-msgv1 INTO lv_msg SEPARATED BY space.
it_final-belnr = t_message-msgv1.
it_final-accnt = lv_accnt.
APPEND it_final.
CLEAR it_final.
IF t_message-msgv1 IS NOT INITIAL.
MESSAGE lv_msg TYPE 'I'.
ENDIF.
ENDIF.
CLEAR it_out.
CLEAR it_bdcdata[].
ENDLOOP.
wa_fieldcat-fieldname = 'ACCNT'.
wa_fieldcat-tabname = 'IT_OUT'.
wa_fieldcat-outputlen = '15'.
wa_fieldcat-ref_tabname = 'LFA1'.
wa_fieldcat-ref_fieldname = 'LIFNR'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'BELNR'.
wa_fieldcat-tabname = 'IT_OUT'.
wa_fieldcat-outputlen = '20'.
wa_fieldcat-ref_tabname = 'BKPF'.
wa_fieldcat-ref_fieldname = 'BELNR'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = it_fieldcat[]
* IT_EVENTS = GT_EVENTS[]
i_save = 'U'
TABLES
t_outtab = it_final.
FORM bdc_dynpro USING program dynpro.
CLEAR wa_bdcdata.
wa_bdcdata-program = program.
wa_bdcdata-dynpro = dynpro.
wa_bdcdata-dynbegin = 'X'.
APPEND wa_bdcdata TO it_bdcdata.
ENDFORM.
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
* IF FVAL <> NODATA.
CLEAR wa_bdcdata.
wa_bdcdata-fnam = fnam.
wa_bdcdata-fval = fval.
APPEND wa_bdcdata TO it_bdcdata.
* ENDIF.
ENDFORM.
TYPES: BEGIN OF ty_out,
accnt TYPE invfo-accnt,
bldat TYPE invfo-bldat,
XBLNR TYPE INVFO-XBLNR,
SGTXT1 TYPE INVFO-SGTXT,
wrbtr TYPE invfo-wrbtr,
zterm TYPE invfo-zterm,
hkont TYPE acgl_item-hkont,
mwskz TYPE acgl_item-mwskz,
sgtxt TYPE acgl_item-sgtxt,
gsber TYPE acgl_item-gsber,
kostl TYPE acgl_item-kostl,
hsn_sac TYPE acgl_item-hsn_sac,
END OF ty_out.
TYPES : BEGIN OF ty_final,
accnt TYPE invfo-accnt,
belnr TYPE bseg-belnr,
END OF ty_final.
DATA lv_wrbtr(16) TYPE c.
DATA p_budat1(10) TYPE c.
DATA p_bldat1(10) TYPE c.
DATA lv_accnt TYPE invfo-accnt.
DATA it_out TYPE TABLE OF ty_out WITH HEADER LINE.
DATA it_final TYPE TABLE OF ty_final WITH HEADER LINE.
DATA: it_bdcdata TYPE TABLE OF bdcdata,
wa_bdcdata TYPE bdcdata,
it_type TYPE truxs_t_text_data,
t_message TYPE TABLE OF bdcmsgcoll WITH HEADER LINE.
DATA it_fieldcat TYPE slis_t_fieldcat_alv.
DATA wa_fieldcat TYPE slis_fieldcat_alv.
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-100.
PARAMETERS : p_bukrs TYPE bkpf-bukrs OBLIGATORY DEFAULT 'TH01',
p_budat TYPE bkpf-budat OBLIGATORY,
p_waers TYPE bkpf-waers OBLIGATORY DEFAULT 'INR',
p_bupla TYPE invfo-bupla OBLIGATORY DEFAULT 'TN01'.
SELECTION-SCREEN END OF BLOCK blk1.
SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME TITLE text-200.
PARAMETER p_file TYPE rlgrap-filename OBLIGATORY.
SELECTION-SCREEN END OF BLOCK blk.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file .
CALL FUNCTION 'F4_FILENAME'
* EXPORTING
* PROGRAM_NAME = SYST-CPROG
* DYNPRO_NUMBER = SYST-DYNNR
* FIELD_NAME = ' '
IMPORTING
file_name = p_file.
START-OF-SELECTION.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_field_seperator = 'X'
i_line_header = 'X'
i_tab_raw_data = it_type
i_filename = p_file
TABLES
i_tab_converted_data = it_out
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
WRITE: p_budat TO p_budat1.
LOOP AT it_out.
CLEAR lv_accnt.
lv_accnt = it_out-accnt.
WRITE: it_out-bldat TO p_bldat1.
PERFORM bdc_dynpro USING 'SAPMF05A' '1100'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=DUMMY'.
PERFORM bdc_field USING 'RF05A-BUSCS'
'R'.
PERFORM bdc_field USING 'BDC_CURSOR'
'INVFO-XMWST'.
PERFORM bdc_field USING 'INVFO-ACCNT'
it_out-accnt.
PERFORM bdc_field USING 'INVFO-BLDAT'
p_bldat1.
PERFORM bdc_field USING 'INVFO-BUDAT'
p_budat1.
PERFORM bdc_field USING 'INVFO-SGTXT'
it_out-sgtxt1.
PERFORM bdc_field USING 'INVFO-XBLNR'
it_out-xblnr.
lv_wrbtr = it_out-wrbtr.
CONDENSE lv_wrbtr.
PERFORM bdc_field USING 'INVFO-WRBTR'
lv_wrbtr.
PERFORM bdc_field USING 'INVFO-WAERS'
p_waers.
PERFORM bdc_field USING 'INVFO-XMWST'
'X'.
PERFORM bdc_field USING 'INVFO-BUPLA'
p_bupla.
PERFORM bdc_dynpro USING 'SAPMF05A' '1100'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=PAYM'.
PERFORM bdc_field USING 'RF05A-BUSCS'
'R'.
PERFORM bdc_field USING 'BDC_CURSOR'
'INVFO-XMWST'.
PERFORM bdc_dynpro USING 'SAPMF05A' '1100'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'INVFO-ZTERM'
it_out-zterm.
PERFORM bdc_field USING 'BDC_CURSOR'
'ACGL_ITEM-HSN_SAC(01)'.
PERFORM bdc_field USING 'ACGL_ITEM-HKONT(01)'
it_out-hkont.
PERFORM bdc_field USING 'ACGL_ITEM-WRBTR(01)'
lv_wrbtr..
PERFORM bdc_field USING 'ACGL_ITEM-MWSKZ(01)'
it_out-mwskz.
PERFORM bdc_field USING 'ACGL_ITEM-SGTXT(01)'
it_out-sgtxt.
PERFORM bdc_field USING 'ACGL_ITEM-GSBER(01)'
it_out-gsber.
PERFORM bdc_field USING 'ACGL_ITEM-KOSTL(01)'
it_out-kostl.
PERFORM bdc_field USING 'ACGL_ITEM-HSN_SAC(01)'
it_out-hsn_sac.
PERFORM bdc_dynpro USING 'SAPMF05A' '1100'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BS'.
CLEAR : t_message, t_message[].
CALL TRANSACTION 'FB60' USING it_bdcdata
MODE 'E' UPDATE 'S' MESSAGES INTO t_message.
READ TABLE t_message WITH KEY msgnr = '312'.
IF sy-subrc = 0.
DATA lv_msg(50) TYPE c.
CLEAR lv_msg.
CONCATENATE 'Document Created' t_message-msgv1 INTO lv_msg SEPARATED BY space.
it_final-belnr = t_message-msgv1.
it_final-accnt = lv_accnt.
APPEND it_final.
CLEAR it_final.
IF t_message-msgv1 IS NOT INITIAL.
MESSAGE lv_msg TYPE 'I'.
ENDIF.
ENDIF.
CLEAR it_out.
CLEAR it_bdcdata[].
ENDLOOP.
wa_fieldcat-fieldname = 'ACCNT'.
wa_fieldcat-tabname = 'IT_OUT'.
wa_fieldcat-outputlen = '15'.
wa_fieldcat-ref_tabname = 'LFA1'.
wa_fieldcat-ref_fieldname = 'LIFNR'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'BELNR'.
wa_fieldcat-tabname = 'IT_OUT'.
wa_fieldcat-outputlen = '20'.
wa_fieldcat-ref_tabname = 'BKPF'.
wa_fieldcat-ref_fieldname = 'BELNR'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = it_fieldcat[]
* IT_EVENTS = GT_EVENTS[]
i_save = 'U'
TABLES
t_outtab = it_final.
FORM bdc_dynpro USING program dynpro.
CLEAR wa_bdcdata.
wa_bdcdata-program = program.
wa_bdcdata-dynpro = dynpro.
wa_bdcdata-dynbegin = 'X'.
APPEND wa_bdcdata TO it_bdcdata.
ENDFORM.
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
* IF FVAL <> NODATA.
CLEAR wa_bdcdata.
wa_bdcdata-fnam = fnam.
wa_bdcdata-fval = fval.
APPEND wa_bdcdata TO it_bdcdata.
* ENDIF.
ENDFORM.
No comments:
Post a Comment