Interfaces (To post Legacy data)
METHOD zpiii_mine11sales_data_to_sape~mine11sales_data_to_sapecc_in.
*** **** INSERT IMPLEMENTATION HERE **** ***
*
TYPES:BEGIN OF ty_message,
l_mstring TYPE t100-text,
END OF ty_message.
DATA lt_suc_message TYPE STANDARD TABLE OF ty_message.
DATA wa_suc_message TYPE ty_message.
DATA lt_suc_message1 TYPE STANDARD TABLE OF zfi_mineii_mail.
DATA wa_suc_message1 TYPE zfi_mineii_mail.
TYPES:BEGIN OF ty_message1,
l_mstring1 TYPE t100-text,
END OF ty_message1.
DATA lt_fail_message TYPE STANDARD TABLE OF ty_message1.
DATA wa_fail_message TYPE ty_message.
DATA lt_fail_message1 TYPE STANDARD TABLE OF zfi_mineii_mail.
DATA wa_fail_message1 TYPE zfi_mineii_mail.
TYPES:
BEGIN OF lty_download,
unit_code TYPE string,
inter_state_flag TYPE string,
region TYPE string,
party_code TYPE string,
da_no TYPE string,
invoice_no TYPE string,
invoice_date TYPE string,
prod_code TYPE string,
scheme_code TYPE string,
gl_code TYPE string,
qty TYPE string,
rate TYPE string,
prod_amt TYPE string,
dr_scheme_code TYPE string,
dr_gl_code TYPE string,
tot_inv_amt TYPE string,
scheme_code1 TYPE string,
gl_code1 TYPE string,
amount1 TYPE string,
scheme_code2 TYPE string,
gl_code2 TYPE string,
amount2 TYPE string,
scheme_code3 TYPE string,
gl_code3 TYPE string,
amount3 TYPE string,
scheme_code4 TYPE string,
gl_code4 TYPE string,
amount4 TYPE string,
scheme_code5 TYPE string,
gl_code5 TYPE string,
amount5 TYPE string,
scheme_code6 TYPE string,
gl_code6 TYPE string,
amount6 TYPE string,
scheme_code7 TYPE string,
gl_code7 TYPE string,
amount7 type string,
scheme_code8 type string,
gl_code8 type string,
amount8 type string,
scheme_code9 type string,
gl_code9 type string,
amount9 type string,
scheme_code10 type string,
gl_code10 type string,
amount10 type string,
user_id type string,
time_stamp type string,
end of lty_download.
TYPES:
BEGIN OF ty_skb1,
saknr TYPE saknr,
altkt TYPE altkt_skb1,
END OF ty_skb1,
BEGIN OF ty_skb1_1,
saknr TYPE saknr,
altkt TYPE string, "ALTKT_SKB1,
END OF ty_skb1_1.
TYPES:
BEGIN OF ty_kna1,
kunnr TYPE kunnr,
sortl TYPE sortl,
END OF ty_kna1.
TYPES:
BEGIN OF ty_minesii,
counter TYPE n LENGTH 10,
unit_code(10),
scheme_code(10),
div_code(10),
party_code TYPE bdc_fval,"(06),
invoice_no TYPE bdc_fval,"(10),
qty TYPE bdc_fval,"(10),
gl_code TYPE bdc_fval,
dr_amt TYPE bdc_fval,
cr_amt TYPE bdc_fval,
kostl TYPE bdc_fval,
prof_cen TYPE bdc_fval,
poskey TYPE bdc_fval,
gl_main_acct TYPE bdc_fval,
END OF ty_minesii.
DATA:
lv_glcode(10) TYPE n,
lv_partycode(06) TYPE n,
lv_counter(05) ,
lv_dramt TYPE string,
* LV_DEBIT TYPE STRING,
lv_debit TYPE dmbtr,
lv_cramt TYPE string,
* LV_CREDIT TYPE STRING,
lv_credit TYPE dmbtr,
lv_difamt TYPE string,
lv_amount_cr TYPE string,
lv_amount_dr TYPE string,
lv_path TYPE string.
DATA:
lt_minesii_sales TYPE zpimine11sales_data_to_sap_tab,
lt_minesii_table TYPE zpimine11sales_data_to_sap_tab,
lwa_minesii_sales TYPE zpimine11sales_data_to_sapecc,
lt_minesii TYPE STANDARD TABLE OF ty_minesii,
lt_download type STANDARD TABLE OF lty_download,
lwa_download type lty_download,
lwa_minesii TYPE ty_minesii,
lwa_climscd TYPE zfi_olimms_cd,
lwa_skb1 TYPE ty_skb1,
lwa_skb1_1 TYPE ty_skb1_1,
lwa_kna1 TYPE ty_kna1,
lwa_elog TYPE zfi_minesiielog,
lwa_minesii_table TYPE zpimine11sales_data_to_sapecc.
DATA:
lt_climscd TYPE TABLE OF zfi_olimms_cd,
lt_skb1 TYPE TABLE OF ty_skb1,
lt_skb1_1 TYPE TABLE OF ty_skb1_1,
lt_kna1 TYPE TABLE OF ty_kna1,
lt_elog TYPE TABLE OF zfi_minesiielog.
CONSTANTS:
lc_bukrs TYPE bukrs VALUE '1000',
lc_dr TYPE newbs VALUE '01',
lc_cr TYPE newbs VALUE '50'.
DATA :
lv_date TYPE string,
lv_time TYPE string.
**-- ABAP07 05.06.2015
**-- Get mine2
lt_minesii_sales[] = input-mine11sales_data_to_sapecc-sales_data[].
** top header part of excel fields.
lwa_download-unit_code = 'Unit Code'.
lwa_download-inter_state_flag = 'Inter State Flag'.
lwa_download-region = 'Region'.
lwa_download-party_code = 'Pary Code'.
lwa_download-da_no = 'DA Number'.
lwa_download-invoice_no = 'Invoice Number'.
lwa_download-invoice_date = 'Invoice Date'.
lwa_download-prod_code = 'Prod Code'.
lwa_download-scheme_code = 'Scheme Code'.
lwa_download-gl_code = 'GL Code'.
lwa_download-qty = 'Qty'.
lwa_download-rate = 'Rate'.
lwa_download-prod_amt = 'Prod Amt'.
lwa_download-dr_scheme_code = 'DR Scheme Code'.
lwa_download-dr_gl_code = 'DR GL Code'.
lwa_download-tot_inv_amt = 'TOT Inv Amt'.
lwa_download-scheme_code1 = 'Scheme Code1'.
lwa_download-gl_code1 = 'GL Code1'.
lwa_download-amount1 = 'Amount1'.
lwa_download-scheme_code2 = 'Scheme Code2'.
lwa_download-gl_code2 = 'GL Code2'.
lwa_download-amount2 = 'Amount2'.
lwa_download-scheme_code3 = 'Scheme Code3'.
lwa_download-gl_code3 = 'GL Code3'.
lwa_download-amount3 = 'Amount3'.
lwa_download-scheme_code4 = 'Scheme Code4'.
lwa_download-gl_code4 = 'GL Code4'.
lwa_download-amount4 = 'Amount4'.
lwa_download-scheme_code5 = 'Scheme Code5'.
lwa_download-gl_code5 = 'GL Code5'.
lwa_download-amount5 = 'Amount5'.
lwa_download-scheme_code6 = 'Scheme Code6'.
lwa_download-gl_code6 = 'GL Code6'.
lwa_download-amount6 = 'Amount6'.
lwa_download-scheme_code7 = 'Scheme Code7'.
lwa_download-gl_code7 = 'GL Code7'.
lwa_download-amount7 = 'Amount7'.
lwa_download-scheme_code8 = 'Scheme Code8'.
lwa_download-gl_code8 = 'GL Code8'.
lwa_download-amount8 = 'Amount8'.
lwa_download-scheme_code9 = 'Scheme Code9'.
lwa_download-gl_code9 = 'GL Code9'.
lwa_download-amount9 = 'Amount9'.
lwa_download-scheme_code10 = 'Scheme Code10'.
lwa_download-gl_code10 = 'GL Code10'.
lwa_download-amount10 = 'Amount10'.
lwa_download-user_id = 'User ID'.
lwa_download-time_stamp = 'Time Stamp'.
append lwa_download to lt_download.
**-- Checking the availability of party code "ABAP07 05.06.2015
**-- Passing mine2 records to another internal table for validation purpose
lt_minesii_table[] = lt_minesii_sales[] .
**-- Sort validation table of mine2
SORT lt_minesii_table.
* DELETE ADJACENT DUPLICATES FROM lt_minesii_table COMPARING party_code.
**-- Fetch Unit Code,Scheme Code,Div.Code,Cost Centre & Profit Centre
SELECT *
FROM zfi_olimms_cd
INTO TABLE lt_climscd.
**Fetch Customer Number
SELECT kunnr
sortl
FROM kna1
INTO TABLE lt_kna1.
**--Fetch GL Account Number
SELECT saknr
altkt
FROM skb1 INTO TABLE lt_skb1
WHERE bukrs EQ lc_bukrs.
**-- ALTERNATE KEYS validations
LOOP AT lt_skb1 INTO lwa_skb1.
** -- delete the leading zeroes
SHIFT lwa_skb1-altkt LEFT DELETING LEADING '0'.
lwa_skb1_1-saknr = lwa_skb1-saknr.
lwa_skb1_1-altkt = lwa_skb1-altkt.
APPEND lwa_skb1_1 TO lt_skb1_1.
CLEAR lwa_skb1_1.
ENDLOOP.
**-- checking for availability of party code in KNA1. " abap07 05.06.2015
LOOP AT lt_minesii_table INTO lwa_minesii_table.
SORT lt_kna1.
READ TABLE lt_kna1 INTO lwa_kna1 WITH KEY sortl = lwa_minesii_table-party_code.
* BINARY SEARCH.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-p_code = lwa_minesii_table-party_code.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted because of Non-availability of Party Code '
lwa_minesii_table-party_code INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
SORT lt_skb1_1.
IF lwa_minesii_table-gl_code IS NOT INITIAL.
***************************read statement for GL_CODE ***********************
*DATA :LV_ALTKT TYPE STRING.
*LV_ALTKT = Lwa_minesii_table-gl_code.
IF lwa_minesii_table-gl_code IS NOT INITIAL.
READ TABLE lt_skb1_1 INTO lwa_skb1_1 WITH KEY altkt = lwa_minesii_table-gl_code ."lwa_minesii_table-gl_code BINARY SEARCH.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-gl_acc = lwa_minesii_table-gl_code.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted because of Non-availability of GL Code '
lwa_minesii_table-gl_code INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
*endif.
*
**-- read statement for DR_GL_CODE
IF lwa_minesii_table-dr_gl_code IS NOT INITIAL.
READ TABLE lt_skb1_1 INTO lwa_skb1_1 WITH KEY altkt = lwa_minesii_table-dr_gl_code .
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-gl_acc = lwa_minesii_table-dr_gl_code.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted because of Non-availability of GL Code '
lwa_minesii_table-dr_gl_code INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- read statement for GL_CODE1
IF lwa_minesii_table-gl_code1 IS NOT INITIAL.
READ TABLE lt_skb1_1 INTO lwa_skb1_1 WITH KEY altkt = lwa_minesii_table-gl_code1 .
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-gl_acc = lwa_minesii_table-gl_code1.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted because of Non-availability of GL Code '
lwa_minesii_table-gl_code1 INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- read statement for GL_CODE2
IF lwa_minesii_table-gl_code2 IS NOT INITIAL.
READ TABLE lt_skb1_1 INTO lwa_skb1_1 WITH KEY altkt = lwa_minesii_table-gl_code2 .
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-gl_acc = lwa_minesii_table-gl_code2.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted because of Non-availability of GL Code '
lwa_minesii_table-gl_code2 INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- read statement for GL_CODE3
IF lwa_minesii_table-gl_code3 IS NOT INITIAL.
READ TABLE lt_skb1_1 INTO lwa_skb1_1 WITH KEY altkt = lwa_minesii_table-gl_code3 .
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-gl_acc = lwa_minesii_table-gl_code3.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted because of Non-availability of GL Code '
lwa_minesii_table-gl_code3 INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- read statement for GL_CODE4
IF lwa_minesii_table-gl_code4 IS NOT INITIAL.
READ TABLE lt_skb1_1 INTO lwa_skb1_1 WITH KEY altkt = lwa_minesii_table-gl_code4.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-gl_acc = lwa_minesii_table-gl_code4.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted because of Non-availability of GL Code '
lwa_minesii_table-gl_code4 INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- read statement for GL_CODE5
IF lwa_minesii_table-gl_code5 IS NOT INITIAL.
READ TABLE lt_skb1_1 INTO lwa_skb1_1 WITH KEY altkt = lwa_minesii_table-gl_code5.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-gl_acc = lwa_minesii_table-gl_code5.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted because of Non-availability of GL Code '
lwa_minesii_table-gl_code5 INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- read statement for GL_CODE6
IF lwa_minesii_table-gl_code6 IS NOT INITIAL.
READ TABLE lt_skb1_1 INTO lwa_skb1_1 WITH KEY altkt = lwa_minesii_table-gl_code6.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-gl_acc = lwa_minesii_table-gl_code6.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted because of Non-availability of GL Code '
lwa_minesii_table-gl_code6 INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- read statement for GL_CODE7
IF lwa_minesii_table-gl_code7 IS NOT INITIAL.
READ TABLE lt_skb1_1 INTO lwa_skb1_1 WITH KEY altkt = lwa_minesii_table-gl_code7.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-gl_acc = lwa_minesii_table-gl_code7.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted because of Non-availability of GL Code '
lwa_minesii_table-gl_code INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- read statement for GL_CODE8
IF lwa_minesii_table-gl_code8 IS NOT INITIAL.
READ TABLE lt_skb1_1 INTO lwa_skb1_1 WITH KEY altkt = lwa_minesii_table-gl_code8.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-gl_acc = lwa_minesii_table-gl_code8.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted because of Non-availability of GL Code '
lwa_minesii_table-gl_code8 INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- read statement for GL_CODE9
IF lwa_minesii_table-gl_code9 IS NOT INITIAL.
READ TABLE lt_skb1_1 INTO lwa_skb1_1 WITH KEY altkt = lwa_minesii_table-gl_code9.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-gl_acc = lwa_minesii_table-gl_code9.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted because of Non-availability of GL Code '
lwa_minesii_table-gl_code9 INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- read statement for GL_CODE10
IF lwa_minesii_table-gl_code10 IS NOT INITIAL.
READ TABLE lt_skb1_1 INTO lwa_skb1_1 WITH KEY altkt = lwa_minesii_table-gl_code10.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-gl_acc = lwa_minesii_table-gl_code10.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted because of Non-availability of GL Code '
lwa_minesii_table-gl_code10 INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
ENDIF.
**-- validations for unit code
IF lt_climscd IS NOT INITIAL.
SORT lt_climscd.
IF lwa_minesii_table-unit_code IS NOT INITIAL.
READ TABLE lt_climscd INTO lwa_climscd WITH KEY unit_code = lwa_minesii_table-unit_code.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted since the combination of Unit Code '
lwa_minesii_table-unit_code 'is not available' INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
ENDIF.
** -- validation for scheme SCHEME_CODE
IF lt_climscd IS NOT INITIAL.
SORT lt_climscd.
IF lwa_minesii_table-scheme_code IS NOT INITIAL.
READ TABLE lt_climscd INTO lwa_climscd WITH KEY scheme_code = lwa_minesii_table-scheme_code.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted since the Scheme Code'
lwa_minesii_table-scheme_code 'is not available' INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- validation for scheme DR_SCHEME CODE
IF lwa_minesii_table-dr_scheme_code IS NOT INITIAL.
READ TABLE lt_climscd INTO lwa_climscd WITH KEY scheme_code = lwa_minesii_table-dr_scheme_code.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-dr_scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted since the Scheme Code'
lwa_minesii_table-dr_scheme_code 'is not available' INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- validation for scheme SCHEME CODE1
IF lwa_minesii_table-scheme_code1 IS NOT INITIAL.
READ TABLE lt_climscd INTO lwa_climscd WITH KEY scheme_code = lwa_minesii_table-scheme_code1.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code1.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted since the Scheme Code'
lwa_minesii_table-scheme_code1 'is not available' INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- validation for scheme SCHEME CODE2
IF lwa_minesii_table-scheme_code2 IS NOT INITIAL.
READ TABLE lt_climscd INTO lwa_climscd WITH KEY scheme_code = lwa_minesii_table-scheme_code2.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code2.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted since the Scheme Code'
lwa_minesii_table-scheme_code2 'is not available' INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- validation for scheme SCHEME CODE3
IF lwa_minesii_table-scheme_code3 IS NOT INITIAL.
READ TABLE lt_climscd INTO lwa_climscd WITH KEY scheme_code = lwa_minesii_table-scheme_code3.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code3.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted since the Scheme Code'
lwa_minesii_table-scheme_code3 'is not available' INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- validation for scheme SCHEME CODE4
IF lwa_minesii_table-scheme_code4 IS NOT INITIAL.
READ TABLE lt_climscd INTO lwa_climscd WITH KEY scheme_code = lwa_minesii_table-scheme_code4.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code4.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted since the Scheme Code'
lwa_minesii_table-scheme_code4 'is not available' INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- validation for scheme SCHEME CODE5
IF lwa_minesii_table-scheme_code5 IS NOT INITIAL.
READ TABLE lt_climscd INTO lwa_climscd WITH KEY scheme_code = lwa_minesii_table-scheme_code5.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code5.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted since the Scheme Code'
lwa_minesii_table-scheme_code5 'is not available' INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- validation for scheme SCHEME CODE6
IF lwa_minesii_table-scheme_code6 IS NOT INITIAL.
READ TABLE lt_climscd INTO lwa_climscd WITH KEY scheme_code = lwa_minesii_table-scheme_code6.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code6.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted since the Scheme Code'
lwa_minesii_table-scheme_code6 'is not available' INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- validation for scheme SCHEME CODE7
IF lwa_minesii_table-scheme_code7 IS NOT INITIAL.
READ TABLE lt_climscd INTO lwa_climscd WITH KEY scheme_code = lwa_minesii_table-scheme_code7.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code7.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted since the Scheme Code'
lwa_minesii_table-scheme_code7 'is not available' INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- validation for scheme SCHEME CODE8
IF lwa_minesii_table-scheme_code8 IS NOT INITIAL.
READ TABLE lt_climscd INTO lwa_climscd WITH KEY scheme_code = lwa_minesii_table-scheme_code8.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code8.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted since the Scheme Code'
lwa_minesii_table-scheme_code8 'is not available' INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- validation for scheme SCHEME CODE9
IF lwa_minesii_table-scheme_code9 IS NOT INITIAL.
READ TABLE lt_climscd INTO lwa_climscd WITH KEY scheme_code = lwa_minesii_table-scheme_code9.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code9.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted since the Scheme Code'
lwa_minesii_table-scheme_code9 'is not available' INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- validation for scheme SCHEME CODE10
IF lwa_minesii_table-scheme_code10 IS NOT INITIAL.
READ TABLE lt_climscd INTO lwa_climscd WITH KEY scheme_code = lwa_minesii_table-scheme_code10.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code10.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted since the Scheme Code'
lwa_minesii_table-scheme_code10 'is not available' INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
ENDIF.
CLEAR lwa_minesii_table.
ENDLOOP.
IF lt_elog IS NOT INITIAL.
DELETE ADJACENT DUPLICATES FROM lt_elog COMPARING ALL FIELDS.
DELETE FROM zfi_minesiielog.
INSERT zfi_minesiielog FROM TABLE lt_elog.
COMMIT WORK.
ENDIF.
IF lt_elog IS INITIAL.
LOOP AT lt_minesii_sales INTO lwa_minesii_sales.
*************
** -- downloading file in excel
lwa_download-unit_code = lwa_minesii_sales-unit_code .
lwa_download-inter_state_flag = lwa_minesii_sales-inter_state_flag .
lwa_download-region = lwa_minesii_sales-region .
lwa_download-party_code = lwa_minesii_sales-party_code .
lwa_download-da_no = lwa_minesii_sales-da_no .
lwa_download-invoice_no = lwa_minesii_sales-invoice_no .
lwa_download-invoice_date = lwa_minesii_sales-invoice_date .
lwa_download-prod_code = lwa_minesii_sales-prod_code .
lwa_download-scheme_code = lwa_minesii_sales-scheme_code .
lwa_download-gl_code = lwa_minesii_sales-gl_code .
lwa_download-qty = lwa_minesii_sales-qty .
lwa_download-rate = lwa_minesii_sales-rate .
lwa_download-prod_amt = lwa_minesii_sales-prod_amt .
lwa_download-dr_scheme_code = lwa_minesii_sales-dr_scheme_code .
lwa_download-dr_gl_code = lwa_minesii_sales-dr_gl_code .
lwa_download-tot_inv_amt = lwa_minesii_sales-tot_inv_amt .
lwa_download-scheme_code1 = lwa_minesii_sales-scheme_code1 .
lwa_download-gl_code1 = lwa_minesii_sales-gl_code1 .
lwa_download-amount1 = lwa_minesii_sales-amount1 .
lwa_download-scheme_code2 = lwa_minesii_sales-scheme_code2 .
lwa_download-gl_code2 = lwa_minesii_sales-gl_code2 .
lwa_download-amount2 = lwa_minesii_sales-amount2 .
lwa_download-scheme_code3 = lwa_minesii_sales-scheme_code3 .
lwa_download-gl_code3 = lwa_minesii_sales-gl_code3 .
lwa_download-amount3 = lwa_minesii_sales-amount3 .
lwa_download-scheme_code4 = lwa_minesii_sales-scheme_code4 .
lwa_download-gl_code4 = lwa_minesii_sales-gl_code4 .
lwa_download-amount4 = lwa_minesii_sales-amount4 .
lwa_download-scheme_code5 = lwa_minesii_sales-scheme_code5 .
lwa_download-gl_code5 = lwa_minesii_sales-gl_code5 .
lwa_download-amount5 = lwa_minesii_sales-amount5 .
lwa_download-scheme_code6 = lwa_minesii_sales-scheme_code6 .
lwa_download-gl_code6 = lwa_minesii_sales-gl_code6 .
lwa_download-amount6 = lwa_minesii_sales-amount6 .
lwa_download-scheme_code7 = lwa_minesii_sales-scheme_code7 .
lwa_download-gl_code7 = lwa_minesii_sales-gl_code7 .
lwa_download-amount7 = lwa_minesii_sales-amount7 .
lwa_download-scheme_code8 = lwa_minesii_sales-scheme_code8 .
lwa_download-gl_code8 = lwa_minesii_sales-gl_code8 .
lwa_download-amount8 = lwa_minesii_sales-amount8 .
lwa_download-scheme_code9 = lwa_minesii_sales-scheme_code9 .
lwa_download-gl_code9 = lwa_minesii_sales-gl_code9 .
lwa_download-amount9 = lwa_minesii_sales-amount9 .
lwa_download-scheme_code10 = lwa_minesii_sales-scheme_code10 .
lwa_download-gl_code10 = lwa_minesii_sales-gl_code10 .
lwa_download-amount10 = lwa_minesii_sales-amount10 .
lwa_download-user_id = lwa_minesii_sales-user_id .
lwa_download-time_stamp = lwa_minesii_sales-time_stamp .
append lwa_download to lt_download.
clear lwa_download.
*************
CLEAR:lwa_minesii-dr_amt,lwa_minesii-cr_amt.
READ TABLE lt_climscd INTO lwa_climscd WITH KEY unit_code = lwa_minesii_sales-unit_code
scheme_code = lwa_minesii_sales-scheme_code
div_code = '95'.
IF sy-subrc = 0.
lwa_minesii-counter = lwa_minesii-counter + 001.
lwa_minesii-unit_code = lwa_climscd-unit_code.
lwa_minesii-scheme_code = lwa_climscd-scheme_code.
lwa_minesii-div_code = lwa_climscd-div_code.
lwa_minesii-dr_amt = lwa_minesii_sales-tot_inv_amt.
lwa_minesii-kostl = lwa_climscd-kostl.
lwa_minesii-prof_cen = lwa_climscd-prof_cnt.
lwa_minesii-poskey = lc_dr.
lwa_minesii-invoice_no = lwa_minesii_sales-invoice_no.
lwa_minesii-qty = lwa_minesii_sales-qty.
lwa_minesii-party_code = lwa_minesii_sales-party_code.
lv_partycode = lwa_minesii_sales-party_code.
READ TABLE lt_kna1 INTO lwa_kna1 WITH KEY sortl = lv_partycode.
IF sy-subrc EQ 0.
lwa_minesii-gl_main_acct = lwa_kna1-kunnr.
ENDIF.
APPEND lwa_minesii TO lt_minesii.
CLEAR:lwa_minesii-gl_code,lv_glcode,lwa_minesii-dr_amt,lwa_minesii-gl_main_acct,lwa_minesii-dr_amt,
lwa_minesii-qty.
lwa_minesii-counter = lwa_minesii-counter.
lwa_minesii-unit_code = lwa_climscd-unit_code.
lwa_minesii-scheme_code = lwa_climscd-scheme_code.
lwa_minesii-div_code = lwa_climscd-div_code.
lwa_minesii-cr_amt = lwa_minesii_sales-prod_amt.
lwa_minesii-kostl = lwa_climscd-kostl.
lwa_minesii-prof_cen = lwa_climscd-prof_cnt.
lwa_minesii-poskey = lc_cr.
lwa_minesii-invoice_no = lwa_minesii_sales-invoice_no.
lwa_minesii-party_code = lwa_minesii_sales-party_code.
lwa_minesii-gl_code = lwa_minesii_sales-gl_code.
lv_glcode = lwa_minesii_sales-gl_code.
READ TABLE lt_skb1 INTO lwa_skb1 WITH KEY altkt = lv_glcode.
IF sy-subrc EQ 0.
lwa_minesii-gl_main_acct = lwa_skb1-saknr.
ENDIF.
APPEND lwa_minesii TO lt_minesii.
CLEAR:lwa_minesii-gl_code,lv_glcode,lwa_minesii-cr_amt,lwa_minesii-gl_main_acct,lwa_minesii-cr_amt.
IF lwa_minesii_sales-gl_code1 IS NOT INITIAL AND
lwa_minesii_sales-scheme_code1 IS NOT INITIAL AND
lwa_minesii_sales-amount1 NE '.00'.
lwa_minesii-counter = lwa_minesii-counter.
lwa_minesii-unit_code = lwa_climscd-unit_code.
lwa_minesii-scheme_code = lwa_climscd-scheme_code.
lwa_minesii-div_code = lwa_climscd-div_code.
lwa_minesii-cr_amt = lwa_minesii_sales-amount1.
lwa_minesii-kostl = lwa_climscd-kostl.
lwa_minesii-prof_cen = lwa_climscd-prof_cnt.
lwa_minesii-poskey = lc_cr.
lwa_minesii-invoice_no = lwa_minesii_sales-invoice_no.
lwa_minesii-party_code = lwa_minesii_sales-party_code.
lwa_minesii-gl_code = lwa_minesii_sales-gl_code1.
lv_glcode = lwa_minesii_sales-gl_code1.
READ TABLE lt_skb1 INTO lwa_skb1 WITH KEY altkt = lv_glcode.
IF sy-subrc EQ 0.
lwa_minesii-gl_main_acct = lwa_skb1-saknr.
ENDIF.
APPEND lwa_minesii TO lt_minesii.
CLEAR:lwa_minesii-gl_code,lv_glcode,lwa_minesii-cr_amt,lwa_minesii-gl_main_acct,lwa_minesii-cr_amt.
ENDIF.
IF lwa_minesii_sales-gl_code2 IS NOT INITIAL AND
lwa_minesii_sales-scheme_code2 IS NOT INITIAL AND
lwa_minesii_sales-amount2 NE '.00'.
lwa_minesii-counter = lwa_minesii-counter.
lwa_minesii-unit_code = lwa_climscd-unit_code.
lwa_minesii-scheme_code = lwa_climscd-scheme_code.
lwa_minesii-div_code = lwa_climscd-div_code.
lwa_minesii-cr_amt = lwa_minesii_sales-amount2.
lwa_minesii-kostl = lwa_climscd-kostl.
lwa_minesii-prof_cen = lwa_climscd-prof_cnt.
lwa_minesii-poskey = lc_cr.
lwa_minesii-invoice_no = lwa_minesii_sales-invoice_no.
lwa_minesii-party_code = lwa_minesii_sales-party_code.
lwa_minesii-gl_code = lwa_minesii_sales-gl_code2.
lv_glcode = lwa_minesii_sales-gl_code2.
READ TABLE lt_skb1 INTO lwa_skb1 WITH KEY altkt = lv_glcode.
IF sy-subrc EQ 0.
lwa_minesii-gl_main_acct = lwa_skb1-saknr.
ENDIF.
APPEND lwa_minesii TO lt_minesii.
CLEAR:lwa_minesii-gl_code,lv_glcode,lwa_minesii-cr_amt,lwa_minesii-gl_main_acct,lwa_minesii-cr_amt.
ENDIF.
IF lwa_minesii_sales-gl_code3 IS NOT INITIAL AND
lwa_minesii_sales-scheme_code3 IS NOT INITIAL AND
lwa_minesii_sales-amount3 NE '.00'.
lwa_minesii-counter = lwa_minesii-counter.
lwa_minesii-unit_code = lwa_climscd-unit_code.
lwa_minesii-scheme_code = lwa_climscd-scheme_code.
lwa_minesii-div_code = lwa_climscd-div_code.
lwa_minesii-cr_amt = lwa_minesii_sales-amount3.
lwa_minesii-kostl = lwa_climscd-kostl.
lwa_minesii-prof_cen = lwa_climscd-prof_cnt.
lwa_minesii-poskey = lc_cr.
lwa_minesii-invoice_no = lwa_minesii_sales-invoice_no.
lwa_minesii-party_code = lwa_minesii_sales-party_code.
lwa_minesii-gl_code = lwa_minesii_sales-gl_code3.
lv_glcode = lwa_minesii_sales-gl_code3.
READ TABLE lt_skb1 INTO lwa_skb1 WITH KEY altkt = lv_glcode.
IF sy-subrc EQ 0.
lwa_minesii-gl_main_acct = lwa_skb1-saknr.
ENDIF.
APPEND lwa_minesii TO lt_minesii.
CLEAR:lwa_minesii-gl_code,lv_glcode,lwa_minesii-cr_amt,lwa_minesii-gl_main_acct,lwa_minesii-cr_amt.
ENDIF.
IF lwa_minesii_sales-gl_code4 IS NOT INITIAL AND
lwa_minesii_sales-scheme_code4 IS NOT INITIAL AND
lwa_minesii_sales-amount4 NE '.00'.
lwa_minesii-counter = lwa_minesii-counter.
lwa_minesii-unit_code = lwa_climscd-unit_code.
lwa_minesii-scheme_code = lwa_climscd-scheme_code.
lwa_minesii-div_code = lwa_climscd-div_code.
lwa_minesii-cr_amt = lwa_minesii_sales-amount4.
lwa_minesii-kostl = lwa_climscd-kostl.
lwa_minesii-prof_cen = lwa_climscd-prof_cnt.
lwa_minesii-poskey = lc_cr.
lwa_minesii-invoice_no = lwa_minesii_sales-invoice_no.
lwa_minesii-party_code = lwa_minesii_sales-party_code.
lwa_minesii-gl_code = lwa_minesii_sales-gl_code4.
lv_glcode = lwa_minesii_sales-gl_code4.
READ TABLE lt_skb1 INTO lwa_skb1 WITH KEY altkt = lv_glcode.
IF sy-subrc EQ 0.
lwa_minesii-gl_main_acct = lwa_skb1-saknr.
ENDIF.
APPEND lwa_minesii TO lt_minesii.
CLEAR:lwa_minesii-gl_code,lv_glcode,lwa_minesii-cr_amt,lwa_minesii-gl_main_acct,lwa_minesii-cr_amt.
ENDIF.
IF lwa_minesii_sales-gl_code5 IS NOT INITIAL AND
lwa_minesii_sales-scheme_code5 IS NOT INITIAL AND
lwa_minesii_sales-amount5 NE '.00'.
lwa_minesii-counter = lwa_minesii-counter.
lwa_minesii-unit_code = lwa_climscd-unit_code.
lwa_minesii-scheme_code = lwa_climscd-scheme_code.
lwa_minesii-div_code = lwa_climscd-div_code.
lwa_minesii-cr_amt = lwa_minesii_sales-amount5.
lwa_minesii-kostl = lwa_climscd-kostl.
lwa_minesii-prof_cen = lwa_climscd-prof_cnt.
lwa_minesii-poskey = lc_cr.
lwa_minesii-invoice_no = lwa_minesii_sales-invoice_no.
lwa_minesii-party_code = lwa_minesii_sales-party_code.
lwa_minesii-gl_code = lwa_minesii_sales-gl_code5.
lv_glcode = lwa_minesii_sales-gl_code5.
READ TABLE lt_skb1 INTO lwa_skb1 WITH KEY altkt = lv_glcode.
IF sy-subrc EQ 0.
lwa_minesii-gl_main_acct = lwa_skb1-saknr.
ENDIF.
APPEND lwa_minesii TO lt_minesii.
CLEAR:lwa_minesii-gl_code,lv_glcode,lwa_minesii-cr_amt,lwa_minesii-gl_main_acct,lwa_minesii-cr_amt.
ENDIF.
IF lwa_minesii_sales-gl_code6 IS NOT INITIAL AND
lwa_minesii_sales-scheme_code6 IS NOT INITIAL AND
lwa_minesii_sales-amount6 NE '.00'.
lwa_minesii-counter = lwa_minesii-counter.
lwa_minesii-unit_code = lwa_climscd-unit_code.
lwa_minesii-scheme_code = lwa_climscd-scheme_code.
lwa_minesii-div_code = lwa_climscd-div_code.
lwa_minesii-cr_amt = lwa_minesii_sales-amount6.
lwa_minesii-kostl = lwa_climscd-kostl.
lwa_minesii-prof_cen = lwa_climscd-prof_cnt.
lwa_minesii-poskey = lc_cr.
lwa_minesii-invoice_no = lwa_minesii_sales-invoice_no.
lwa_minesii-party_code = lwa_minesii_sales-party_code.
lwa_minesii-gl_code = lwa_minesii_sales-gl_code6.
lv_glcode = lwa_minesii_sales-gl_code6.
READ TABLE lt_skb1 INTO lwa_skb1 WITH KEY altkt = lv_glcode.
IF sy-subrc EQ 0.
lwa_minesii-gl_main_acct = lwa_skb1-saknr.
ENDIF.
APPEND lwa_minesii TO lt_minesii.
CLEAR:lwa_minesii-gl_code,lv_glcode,lwa_minesii-cr_amt,lwa_minesii-gl_main_acct,lwa_minesii-cr_amt.
ENDIF.
IF lwa_minesii_sales-gl_code7 IS NOT INITIAL AND
lwa_minesii_sales-scheme_code7 IS NOT INITIAL AND
lwa_minesii_sales-amount7 NE '.00'.
lwa_minesii-counter = lwa_minesii-counter.
lwa_minesii-unit_code = lwa_climscd-unit_code.
lwa_minesii-scheme_code = lwa_climscd-scheme_code.
lwa_minesii-div_code = lwa_climscd-div_code.
lwa_minesii-cr_amt = lwa_minesii_sales-amount7.
lwa_minesii-kostl = lwa_climscd-kostl.
lwa_minesii-prof_cen = lwa_climscd-prof_cnt.
lwa_minesii-poskey = lc_cr.
lwa_minesii-invoice_no = lwa_minesii_sales-invoice_no.
lwa_minesii-party_code = lwa_minesii_sales-party_code.
lwa_minesii-gl_code = lwa_minesii_sales-gl_code7.
lv_glcode = lwa_minesii_sales-gl_code7.
READ TABLE lt_skb1 INTO lwa_skb1 WITH KEY altkt = lv_glcode.
IF sy-subrc EQ 0.
lwa_minesii-gl_main_acct = lwa_skb1-saknr.
ENDIF.
APPEND lwa_minesii TO lt_minesii.
CLEAR:lwa_minesii-gl_code,lv_glcode,lwa_minesii-cr_amt,lwa_minesii-gl_main_acct,lwa_minesii-cr_amt.
ENDIF.
IF lwa_minesii_sales-gl_code8 IS NOT INITIAL AND
lwa_minesii_sales-scheme_code8 IS NOT INITIAL AND
lwa_minesii_sales-amount8 NE '.00'.
lwa_minesii-counter = lwa_minesii-counter.
lwa_minesii-unit_code = lwa_climscd-unit_code.
lwa_minesii-scheme_code = lwa_climscd-scheme_code.
lwa_minesii-div_code = lwa_climscd-div_code.
lwa_minesii-cr_amt = lwa_minesii_sales-amount8.
lwa_minesii-kostl = lwa_climscd-kostl.
lwa_minesii-prof_cen = lwa_climscd-prof_cnt.
lwa_minesii-poskey = lc_cr.
lwa_minesii-invoice_no = lwa_minesii_sales-invoice_no.
lwa_minesii-party_code = lwa_minesii_sales-party_code.
lwa_minesii-gl_code = lwa_minesii_sales-gl_code8.
lv_glcode = lwa_minesii_sales-gl_code8.
READ TABLE lt_skb1 INTO lwa_skb1 WITH KEY altkt = lv_glcode.
IF sy-subrc EQ 0.
lwa_minesii-gl_main_acct = lwa_skb1-saknr.
ENDIF.
APPEND lwa_minesii TO lt_minesii.
CLEAR:lwa_minesii-gl_code,lv_glcode,lwa_minesii-cr_amt,lwa_minesii-gl_main_acct,lwa_minesii-cr_amt.
ENDIF.
IF lwa_minesii_sales-gl_code9 IS NOT INITIAL AND
lwa_minesii_sales-scheme_code9 IS NOT INITIAL AND
lwa_minesii_sales-amount9 NE '.00'.
lwa_minesii-counter = lwa_minesii-counter.
lwa_minesii-unit_code = lwa_climscd-unit_code.
lwa_minesii-scheme_code = lwa_climscd-scheme_code.
lwa_minesii-div_code = lwa_climscd-div_code.
lwa_minesii-cr_amt = lwa_minesii_sales-amount9.
lwa_minesii-kostl = lwa_climscd-kostl.
lwa_minesii-prof_cen = lwa_climscd-prof_cnt.
lwa_minesii-poskey = lc_cr.
lwa_minesii-invoice_no = lwa_minesii_sales-invoice_no.
lwa_minesii-party_code = lwa_minesii_sales-party_code.
lwa_minesii-gl_code = lwa_minesii_sales-gl_code9.
lv_glcode = lwa_minesii_sales-gl_code9.
READ TABLE lt_skb1 INTO lwa_skb1 WITH KEY altkt = lv_glcode.
IF sy-subrc EQ 0.
lwa_minesii-gl_main_acct = lwa_skb1-saknr.
ENDIF.
APPEND lwa_minesii TO lt_minesii.
CLEAR:lwa_minesii-gl_code,lv_glcode,lwa_minesii-cr_amt,lwa_minesii-gl_main_acct,lwa_minesii-cr_amt.
ENDIF.
IF lwa_minesii_sales-gl_code10 IS NOT INITIAL AND
lwa_minesii_sales-scheme_code10 IS NOT INITIAL AND
lwa_minesii_sales-amount10 NE '.00'.
lwa_minesii-counter = lwa_minesii-counter.
lwa_minesii-unit_code = lwa_climscd-unit_code.
lwa_minesii-scheme_code = lwa_climscd-scheme_code.
lwa_minesii-div_code = lwa_climscd-div_code.
lwa_minesii-cr_amt = lwa_minesii_sales-amount10.
lwa_minesii-kostl = lwa_climscd-kostl.
lwa_minesii-prof_cen = lwa_climscd-prof_cnt.
lwa_minesii-poskey = lc_cr.
lwa_minesii-invoice_no = lwa_minesii_sales-invoice_no.
lwa_minesii-party_code = lwa_minesii_sales-party_code.
lwa_minesii-gl_code = lwa_minesii_sales-gl_code10.
lv_glcode = lwa_minesii_sales-gl_code10.
READ TABLE lt_skb1 INTO lwa_skb1 WITH KEY altkt = lv_glcode.
IF sy-subrc EQ 0.
lwa_minesii-gl_main_acct = lwa_skb1-saknr.
ENDIF.
APPEND lwa_minesii TO lt_minesii.
CLEAR:lwa_minesii-gl_code,lv_glcode,lwa_minesii-cr_amt,lwa_minesii-gl_main_acct,lwa_minesii-cr_amt.
ENDIF.
**Validation checking for debit & credit for every invoice before posting
CLEAR:lv_debit,lv_credit,lv_difamt,lv_amount_cr,lv_amount_dr.
LOOP AT lt_minesii INTO lwa_minesii WHERE invoice_no = lwa_minesii-invoice_no.
lv_debit = lv_debit + lwa_minesii-dr_amt.
lv_credit = lv_credit + lwa_minesii-cr_amt.
ENDLOOP.
IF lv_credit EQ lv_debit.
*
ELSE.
lwa_elog-invoice_no = lwa_minesii-invoice_no.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted because of Credit/Debit Missmatch' INTO
lwa_elog-inv_mesg SEPARATED BY space.
APPEND lwa_elog TO lt_elog.
DELETE lt_minesii WHERE invoice_no = lwa_elog-invoice_no.
CLEAR lwa_elog.
ENDIF.
ELSEIF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_sales-invoice_no.
CONCATENATE 'Unit Code' lwa_minesii_sales-unit_code
'Scheme Code' lwa_minesii_sales-scheme_code 'Division Code' '95'
'Combination not maintained in table'
INTO lwa_elog-inv_mesg SEPARATED BY space.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
* LV_ERROR = 'X'.
* EXIT.
ENDIF.
* CLEAR:LWA_MINESII.
* ENDIF.
* DELETE LT_MINESII WHERE CR_AMT EQ '0' AND DR_AMT NE '0'.
ENDLOOP.
******* DOWNLOAD EXCEL
**First Download
IF sy-mandt+0(1) = '2'.
CONCATENATE 'C:\INTERFACES\MINEII\DEV\SAP_MINEII' sy-mandt sy-datum '.XLS' INTO lv_path.
ELSEIF sy-mandt+0(1) = '3'.
CONCATENATE 'C:\INTERFACES\MINEII\QTY\SAP_MINEII' sy-mandt sy-datum '.XLS' INTO lv_path.
ELSEIF sy-mandt+0(1) = '4'.
CONCATENATE 'C:\INTERFACES\MINEII\PRD\SAP_MINEII' sy-mandt sy-datum '.XLS' INTO lv_path.
ENDIF.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = lv_path
filetype = 'ASC'
write_field_separator = 'X'
CHANGING
data_tab = lt_download
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
not_supported_by_gui = 22
error_no_gui = 23
OTHERS = 24.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
*******
DELETE FROM zfi_minesiielog.
COMMIT WORK.
IF lt_elog IS NOT INITIAL.
INSERT zfi_minesiielog FROM TABLE lt_elog.
IF sy-subrc EQ 0.
COMMIT WORK.
ENDIF.
ENDIF.
IF lt_elog IS INITIAL.
CALL FUNCTION 'ZFI_INTERFACE_MINESII'
TABLES
lt_minesii = lt_minesii[]
lt_elog = lt_elog[].
**Getting Success and Failure messages from BDC
REFRESH lt_suc_message[].
REFRESH lt_fail_message[].
IMPORT lt_suc_message TO lt_suc_message[] FROM MEMORY ID 'SUCCESS'.
IMPORT lt_fail_message TO lt_fail_message[] FROM MEMORY ID 'FAIL'.
***logic for mail
DATA lv_str(30).
DATA lv_str1(30).
lv_str = 'Posted Successfully'.
lv_str1 = 'Posting Failed'.
LOOP AT lt_suc_message INTO wa_suc_message.
wa_suc_message1-mandt = sy-mandt.
wa_suc_message1-message = wa_suc_message-l_mstring.
CONCATENATE wa_suc_message1-message lv_str INTO wa_suc_message1-message SEPARATED BY space.
APPEND wa_suc_message1 TO lt_suc_message1.
CLEAR:wa_suc_message1,wa_suc_message.
ENDLOOP.
SORT lt_suc_message1 ASCENDING BY mandt message.
DELETE ADJACENT DUPLICATES FROM lt_suc_message1 COMPARING mandt message.
LOOP AT lt_fail_message INTO wa_fail_message.
wa_fail_message1-mandt = sy-mandt.
wa_fail_message1-message = wa_fail_message-l_mstring.
CONCATENATE wa_fail_message1-message lv_str1 INTO wa_fail_message1-message SEPARATED BY space.
APPEND wa_fail_message1 TO lt_fail_message1.
CLEAR:wa_fail_message1,wa_fail_message.
ENDLOOP.
SORT lt_fail_message1 ASCENDING BY mandt message.
DELETE ADJACENT DUPLICATES FROM lt_fail_message1 COMPARING mandt message.
IF lt_suc_message1[] IS NOT INITIAL.
CALL FUNCTION 'ZSEND_MAIL_MINEII'
TABLES
lt_mail = lt_suc_message1[].
ENDIF.
IF lt_fail_message1[] IS NOT INITIAL.
CALL FUNCTION 'ZSEND_MAIL_MINEII'
TABLES
lt_mail = lt_fail_message1[].
ENDIF.
ENDIF.
ENDIF. "for error log (Non-availability of party code)
ENDMETHOD.
*** **** INSERT IMPLEMENTATION HERE **** ***
*
TYPES:BEGIN OF ty_message,
l_mstring TYPE t100-text,
END OF ty_message.
DATA lt_suc_message TYPE STANDARD TABLE OF ty_message.
DATA wa_suc_message TYPE ty_message.
DATA lt_suc_message1 TYPE STANDARD TABLE OF zfi_mineii_mail.
DATA wa_suc_message1 TYPE zfi_mineii_mail.
TYPES:BEGIN OF ty_message1,
l_mstring1 TYPE t100-text,
END OF ty_message1.
DATA lt_fail_message TYPE STANDARD TABLE OF ty_message1.
DATA wa_fail_message TYPE ty_message.
DATA lt_fail_message1 TYPE STANDARD TABLE OF zfi_mineii_mail.
DATA wa_fail_message1 TYPE zfi_mineii_mail.
TYPES:
BEGIN OF lty_download,
unit_code TYPE string,
inter_state_flag TYPE string,
region TYPE string,
party_code TYPE string,
da_no TYPE string,
invoice_no TYPE string,
invoice_date TYPE string,
prod_code TYPE string,
scheme_code TYPE string,
gl_code TYPE string,
qty TYPE string,
rate TYPE string,
prod_amt TYPE string,
dr_scheme_code TYPE string,
dr_gl_code TYPE string,
tot_inv_amt TYPE string,
scheme_code1 TYPE string,
gl_code1 TYPE string,
amount1 TYPE string,
scheme_code2 TYPE string,
gl_code2 TYPE string,
amount2 TYPE string,
scheme_code3 TYPE string,
gl_code3 TYPE string,
amount3 TYPE string,
scheme_code4 TYPE string,
gl_code4 TYPE string,
amount4 TYPE string,
scheme_code5 TYPE string,
gl_code5 TYPE string,
amount5 TYPE string,
scheme_code6 TYPE string,
gl_code6 TYPE string,
amount6 TYPE string,
scheme_code7 TYPE string,
gl_code7 TYPE string,
amount7 type string,
scheme_code8 type string,
gl_code8 type string,
amount8 type string,
scheme_code9 type string,
gl_code9 type string,
amount9 type string,
scheme_code10 type string,
gl_code10 type string,
amount10 type string,
user_id type string,
time_stamp type string,
end of lty_download.
TYPES:
BEGIN OF ty_skb1,
saknr TYPE saknr,
altkt TYPE altkt_skb1,
END OF ty_skb1,
BEGIN OF ty_skb1_1,
saknr TYPE saknr,
altkt TYPE string, "ALTKT_SKB1,
END OF ty_skb1_1.
TYPES:
BEGIN OF ty_kna1,
kunnr TYPE kunnr,
sortl TYPE sortl,
END OF ty_kna1.
TYPES:
BEGIN OF ty_minesii,
counter TYPE n LENGTH 10,
unit_code(10),
scheme_code(10),
div_code(10),
party_code TYPE bdc_fval,"(06),
invoice_no TYPE bdc_fval,"(10),
qty TYPE bdc_fval,"(10),
gl_code TYPE bdc_fval,
dr_amt TYPE bdc_fval,
cr_amt TYPE bdc_fval,
kostl TYPE bdc_fval,
prof_cen TYPE bdc_fval,
poskey TYPE bdc_fval,
gl_main_acct TYPE bdc_fval,
END OF ty_minesii.
DATA:
lv_glcode(10) TYPE n,
lv_partycode(06) TYPE n,
lv_counter(05) ,
lv_dramt TYPE string,
* LV_DEBIT TYPE STRING,
lv_debit TYPE dmbtr,
lv_cramt TYPE string,
* LV_CREDIT TYPE STRING,
lv_credit TYPE dmbtr,
lv_difamt TYPE string,
lv_amount_cr TYPE string,
lv_amount_dr TYPE string,
lv_path TYPE string.
DATA:
lt_minesii_sales TYPE zpimine11sales_data_to_sap_tab,
lt_minesii_table TYPE zpimine11sales_data_to_sap_tab,
lwa_minesii_sales TYPE zpimine11sales_data_to_sapecc,
lt_minesii TYPE STANDARD TABLE OF ty_minesii,
lt_download type STANDARD TABLE OF lty_download,
lwa_download type lty_download,
lwa_minesii TYPE ty_minesii,
lwa_climscd TYPE zfi_olimms_cd,
lwa_skb1 TYPE ty_skb1,
lwa_skb1_1 TYPE ty_skb1_1,
lwa_kna1 TYPE ty_kna1,
lwa_elog TYPE zfi_minesiielog,
lwa_minesii_table TYPE zpimine11sales_data_to_sapecc.
DATA:
lt_climscd TYPE TABLE OF zfi_olimms_cd,
lt_skb1 TYPE TABLE OF ty_skb1,
lt_skb1_1 TYPE TABLE OF ty_skb1_1,
lt_kna1 TYPE TABLE OF ty_kna1,
lt_elog TYPE TABLE OF zfi_minesiielog.
CONSTANTS:
lc_bukrs TYPE bukrs VALUE '1000',
lc_dr TYPE newbs VALUE '01',
lc_cr TYPE newbs VALUE '50'.
DATA :
lv_date TYPE string,
lv_time TYPE string.
**-- ABAP07 05.06.2015
**-- Get mine2
lt_minesii_sales[] = input-mine11sales_data_to_sapecc-sales_data[].
** top header part of excel fields.
lwa_download-unit_code = 'Unit Code'.
lwa_download-inter_state_flag = 'Inter State Flag'.
lwa_download-region = 'Region'.
lwa_download-party_code = 'Pary Code'.
lwa_download-da_no = 'DA Number'.
lwa_download-invoice_no = 'Invoice Number'.
lwa_download-invoice_date = 'Invoice Date'.
lwa_download-prod_code = 'Prod Code'.
lwa_download-scheme_code = 'Scheme Code'.
lwa_download-gl_code = 'GL Code'.
lwa_download-qty = 'Qty'.
lwa_download-rate = 'Rate'.
lwa_download-prod_amt = 'Prod Amt'.
lwa_download-dr_scheme_code = 'DR Scheme Code'.
lwa_download-dr_gl_code = 'DR GL Code'.
lwa_download-tot_inv_amt = 'TOT Inv Amt'.
lwa_download-scheme_code1 = 'Scheme Code1'.
lwa_download-gl_code1 = 'GL Code1'.
lwa_download-amount1 = 'Amount1'.
lwa_download-scheme_code2 = 'Scheme Code2'.
lwa_download-gl_code2 = 'GL Code2'.
lwa_download-amount2 = 'Amount2'.
lwa_download-scheme_code3 = 'Scheme Code3'.
lwa_download-gl_code3 = 'GL Code3'.
lwa_download-amount3 = 'Amount3'.
lwa_download-scheme_code4 = 'Scheme Code4'.
lwa_download-gl_code4 = 'GL Code4'.
lwa_download-amount4 = 'Amount4'.
lwa_download-scheme_code5 = 'Scheme Code5'.
lwa_download-gl_code5 = 'GL Code5'.
lwa_download-amount5 = 'Amount5'.
lwa_download-scheme_code6 = 'Scheme Code6'.
lwa_download-gl_code6 = 'GL Code6'.
lwa_download-amount6 = 'Amount6'.
lwa_download-scheme_code7 = 'Scheme Code7'.
lwa_download-gl_code7 = 'GL Code7'.
lwa_download-amount7 = 'Amount7'.
lwa_download-scheme_code8 = 'Scheme Code8'.
lwa_download-gl_code8 = 'GL Code8'.
lwa_download-amount8 = 'Amount8'.
lwa_download-scheme_code9 = 'Scheme Code9'.
lwa_download-gl_code9 = 'GL Code9'.
lwa_download-amount9 = 'Amount9'.
lwa_download-scheme_code10 = 'Scheme Code10'.
lwa_download-gl_code10 = 'GL Code10'.
lwa_download-amount10 = 'Amount10'.
lwa_download-user_id = 'User ID'.
lwa_download-time_stamp = 'Time Stamp'.
append lwa_download to lt_download.
**-- Checking the availability of party code "ABAP07 05.06.2015
**-- Passing mine2 records to another internal table for validation purpose
lt_minesii_table[] = lt_minesii_sales[] .
**-- Sort validation table of mine2
SORT lt_minesii_table.
* DELETE ADJACENT DUPLICATES FROM lt_minesii_table COMPARING party_code.
**-- Fetch Unit Code,Scheme Code,Div.Code,Cost Centre & Profit Centre
SELECT *
FROM zfi_olimms_cd
INTO TABLE lt_climscd.
**Fetch Customer Number
SELECT kunnr
sortl
FROM kna1
INTO TABLE lt_kna1.
**--Fetch GL Account Number
SELECT saknr
altkt
FROM skb1 INTO TABLE lt_skb1
WHERE bukrs EQ lc_bukrs.
**-- ALTERNATE KEYS validations
LOOP AT lt_skb1 INTO lwa_skb1.
** -- delete the leading zeroes
SHIFT lwa_skb1-altkt LEFT DELETING LEADING '0'.
lwa_skb1_1-saknr = lwa_skb1-saknr.
lwa_skb1_1-altkt = lwa_skb1-altkt.
APPEND lwa_skb1_1 TO lt_skb1_1.
CLEAR lwa_skb1_1.
ENDLOOP.
**-- checking for availability of party code in KNA1. " abap07 05.06.2015
LOOP AT lt_minesii_table INTO lwa_minesii_table.
SORT lt_kna1.
READ TABLE lt_kna1 INTO lwa_kna1 WITH KEY sortl = lwa_minesii_table-party_code.
* BINARY SEARCH.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-p_code = lwa_minesii_table-party_code.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted because of Non-availability of Party Code '
lwa_minesii_table-party_code INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
SORT lt_skb1_1.
IF lwa_minesii_table-gl_code IS NOT INITIAL.
***************************read statement for GL_CODE ***********************
*DATA :LV_ALTKT TYPE STRING.
*LV_ALTKT = Lwa_minesii_table-gl_code.
IF lwa_minesii_table-gl_code IS NOT INITIAL.
READ TABLE lt_skb1_1 INTO lwa_skb1_1 WITH KEY altkt = lwa_minesii_table-gl_code ."lwa_minesii_table-gl_code BINARY SEARCH.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-gl_acc = lwa_minesii_table-gl_code.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted because of Non-availability of GL Code '
lwa_minesii_table-gl_code INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
*endif.
*
**-- read statement for DR_GL_CODE
IF lwa_minesii_table-dr_gl_code IS NOT INITIAL.
READ TABLE lt_skb1_1 INTO lwa_skb1_1 WITH KEY altkt = lwa_minesii_table-dr_gl_code .
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-gl_acc = lwa_minesii_table-dr_gl_code.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted because of Non-availability of GL Code '
lwa_minesii_table-dr_gl_code INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- read statement for GL_CODE1
IF lwa_minesii_table-gl_code1 IS NOT INITIAL.
READ TABLE lt_skb1_1 INTO lwa_skb1_1 WITH KEY altkt = lwa_minesii_table-gl_code1 .
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-gl_acc = lwa_minesii_table-gl_code1.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted because of Non-availability of GL Code '
lwa_minesii_table-gl_code1 INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- read statement for GL_CODE2
IF lwa_minesii_table-gl_code2 IS NOT INITIAL.
READ TABLE lt_skb1_1 INTO lwa_skb1_1 WITH KEY altkt = lwa_minesii_table-gl_code2 .
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-gl_acc = lwa_minesii_table-gl_code2.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted because of Non-availability of GL Code '
lwa_minesii_table-gl_code2 INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- read statement for GL_CODE3
IF lwa_minesii_table-gl_code3 IS NOT INITIAL.
READ TABLE lt_skb1_1 INTO lwa_skb1_1 WITH KEY altkt = lwa_minesii_table-gl_code3 .
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-gl_acc = lwa_minesii_table-gl_code3.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted because of Non-availability of GL Code '
lwa_minesii_table-gl_code3 INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- read statement for GL_CODE4
IF lwa_minesii_table-gl_code4 IS NOT INITIAL.
READ TABLE lt_skb1_1 INTO lwa_skb1_1 WITH KEY altkt = lwa_minesii_table-gl_code4.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-gl_acc = lwa_minesii_table-gl_code4.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted because of Non-availability of GL Code '
lwa_minesii_table-gl_code4 INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- read statement for GL_CODE5
IF lwa_minesii_table-gl_code5 IS NOT INITIAL.
READ TABLE lt_skb1_1 INTO lwa_skb1_1 WITH KEY altkt = lwa_minesii_table-gl_code5.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-gl_acc = lwa_minesii_table-gl_code5.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted because of Non-availability of GL Code '
lwa_minesii_table-gl_code5 INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- read statement for GL_CODE6
IF lwa_minesii_table-gl_code6 IS NOT INITIAL.
READ TABLE lt_skb1_1 INTO lwa_skb1_1 WITH KEY altkt = lwa_minesii_table-gl_code6.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-gl_acc = lwa_minesii_table-gl_code6.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted because of Non-availability of GL Code '
lwa_minesii_table-gl_code6 INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- read statement for GL_CODE7
IF lwa_minesii_table-gl_code7 IS NOT INITIAL.
READ TABLE lt_skb1_1 INTO lwa_skb1_1 WITH KEY altkt = lwa_minesii_table-gl_code7.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-gl_acc = lwa_minesii_table-gl_code7.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted because of Non-availability of GL Code '
lwa_minesii_table-gl_code INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- read statement for GL_CODE8
IF lwa_minesii_table-gl_code8 IS NOT INITIAL.
READ TABLE lt_skb1_1 INTO lwa_skb1_1 WITH KEY altkt = lwa_minesii_table-gl_code8.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-gl_acc = lwa_minesii_table-gl_code8.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted because of Non-availability of GL Code '
lwa_minesii_table-gl_code8 INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- read statement for GL_CODE9
IF lwa_minesii_table-gl_code9 IS NOT INITIAL.
READ TABLE lt_skb1_1 INTO lwa_skb1_1 WITH KEY altkt = lwa_minesii_table-gl_code9.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-gl_acc = lwa_minesii_table-gl_code9.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted because of Non-availability of GL Code '
lwa_minesii_table-gl_code9 INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- read statement for GL_CODE10
IF lwa_minesii_table-gl_code10 IS NOT INITIAL.
READ TABLE lt_skb1_1 INTO lwa_skb1_1 WITH KEY altkt = lwa_minesii_table-gl_code10.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-gl_acc = lwa_minesii_table-gl_code10.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted because of Non-availability of GL Code '
lwa_minesii_table-gl_code10 INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
ENDIF.
**-- validations for unit code
IF lt_climscd IS NOT INITIAL.
SORT lt_climscd.
IF lwa_minesii_table-unit_code IS NOT INITIAL.
READ TABLE lt_climscd INTO lwa_climscd WITH KEY unit_code = lwa_minesii_table-unit_code.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted since the combination of Unit Code '
lwa_minesii_table-unit_code 'is not available' INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
ENDIF.
** -- validation for scheme SCHEME_CODE
IF lt_climscd IS NOT INITIAL.
SORT lt_climscd.
IF lwa_minesii_table-scheme_code IS NOT INITIAL.
READ TABLE lt_climscd INTO lwa_climscd WITH KEY scheme_code = lwa_minesii_table-scheme_code.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted since the Scheme Code'
lwa_minesii_table-scheme_code 'is not available' INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- validation for scheme DR_SCHEME CODE
IF lwa_minesii_table-dr_scheme_code IS NOT INITIAL.
READ TABLE lt_climscd INTO lwa_climscd WITH KEY scheme_code = lwa_minesii_table-dr_scheme_code.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-dr_scheme_code.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted since the Scheme Code'
lwa_minesii_table-dr_scheme_code 'is not available' INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- validation for scheme SCHEME CODE1
IF lwa_minesii_table-scheme_code1 IS NOT INITIAL.
READ TABLE lt_climscd INTO lwa_climscd WITH KEY scheme_code = lwa_minesii_table-scheme_code1.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code1.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted since the Scheme Code'
lwa_minesii_table-scheme_code1 'is not available' INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- validation for scheme SCHEME CODE2
IF lwa_minesii_table-scheme_code2 IS NOT INITIAL.
READ TABLE lt_climscd INTO lwa_climscd WITH KEY scheme_code = lwa_minesii_table-scheme_code2.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code2.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted since the Scheme Code'
lwa_minesii_table-scheme_code2 'is not available' INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- validation for scheme SCHEME CODE3
IF lwa_minesii_table-scheme_code3 IS NOT INITIAL.
READ TABLE lt_climscd INTO lwa_climscd WITH KEY scheme_code = lwa_minesii_table-scheme_code3.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code3.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted since the Scheme Code'
lwa_minesii_table-scheme_code3 'is not available' INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- validation for scheme SCHEME CODE4
IF lwa_minesii_table-scheme_code4 IS NOT INITIAL.
READ TABLE lt_climscd INTO lwa_climscd WITH KEY scheme_code = lwa_minesii_table-scheme_code4.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code4.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted since the Scheme Code'
lwa_minesii_table-scheme_code4 'is not available' INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- validation for scheme SCHEME CODE5
IF lwa_minesii_table-scheme_code5 IS NOT INITIAL.
READ TABLE lt_climscd INTO lwa_climscd WITH KEY scheme_code = lwa_minesii_table-scheme_code5.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code5.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted since the Scheme Code'
lwa_minesii_table-scheme_code5 'is not available' INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- validation for scheme SCHEME CODE6
IF lwa_minesii_table-scheme_code6 IS NOT INITIAL.
READ TABLE lt_climscd INTO lwa_climscd WITH KEY scheme_code = lwa_minesii_table-scheme_code6.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code6.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted since the Scheme Code'
lwa_minesii_table-scheme_code6 'is not available' INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- validation for scheme SCHEME CODE7
IF lwa_minesii_table-scheme_code7 IS NOT INITIAL.
READ TABLE lt_climscd INTO lwa_climscd WITH KEY scheme_code = lwa_minesii_table-scheme_code7.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code7.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted since the Scheme Code'
lwa_minesii_table-scheme_code7 'is not available' INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- validation for scheme SCHEME CODE8
IF lwa_minesii_table-scheme_code8 IS NOT INITIAL.
READ TABLE lt_climscd INTO lwa_climscd WITH KEY scheme_code = lwa_minesii_table-scheme_code8.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code8.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted since the Scheme Code'
lwa_minesii_table-scheme_code8 'is not available' INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- validation for scheme SCHEME CODE9
IF lwa_minesii_table-scheme_code9 IS NOT INITIAL.
READ TABLE lt_climscd INTO lwa_climscd WITH KEY scheme_code = lwa_minesii_table-scheme_code9.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code9.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted since the Scheme Code'
lwa_minesii_table-scheme_code9 'is not available' INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
**-- validation for scheme SCHEME CODE10
IF lwa_minesii_table-scheme_code10 IS NOT INITIAL.
READ TABLE lt_climscd INTO lwa_climscd WITH KEY scheme_code = lwa_minesii_table-scheme_code10.
IF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_table-invoice_no.
lwa_elog-unit_code = lwa_minesii_table-unit_code.
lwa_elog-scheme_code = lwa_minesii_table-scheme_code10.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted since the Scheme Code'
lwa_minesii_table-scheme_code10 'is not available' INTO
lwa_elog-inv_mesg SEPARATED BY space.
CONCATENATE sy-datum+6(2)'.' sy-datum+4(2)'.' sy-datum+0(4) INTO lv_date.
CONDENSE lv_date.
lwa_elog-zdate = lv_date.
lwa_elog-ztime = sy-uzeit.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
ENDIF.
ENDIF.
ENDIF.
CLEAR lwa_minesii_table.
ENDLOOP.
IF lt_elog IS NOT INITIAL.
DELETE ADJACENT DUPLICATES FROM lt_elog COMPARING ALL FIELDS.
DELETE FROM zfi_minesiielog.
INSERT zfi_minesiielog FROM TABLE lt_elog.
COMMIT WORK.
ENDIF.
IF lt_elog IS INITIAL.
LOOP AT lt_minesii_sales INTO lwa_minesii_sales.
*************
** -- downloading file in excel
lwa_download-unit_code = lwa_minesii_sales-unit_code .
lwa_download-inter_state_flag = lwa_minesii_sales-inter_state_flag .
lwa_download-region = lwa_minesii_sales-region .
lwa_download-party_code = lwa_minesii_sales-party_code .
lwa_download-da_no = lwa_minesii_sales-da_no .
lwa_download-invoice_no = lwa_minesii_sales-invoice_no .
lwa_download-invoice_date = lwa_minesii_sales-invoice_date .
lwa_download-prod_code = lwa_minesii_sales-prod_code .
lwa_download-scheme_code = lwa_minesii_sales-scheme_code .
lwa_download-gl_code = lwa_minesii_sales-gl_code .
lwa_download-qty = lwa_minesii_sales-qty .
lwa_download-rate = lwa_minesii_sales-rate .
lwa_download-prod_amt = lwa_minesii_sales-prod_amt .
lwa_download-dr_scheme_code = lwa_minesii_sales-dr_scheme_code .
lwa_download-dr_gl_code = lwa_minesii_sales-dr_gl_code .
lwa_download-tot_inv_amt = lwa_minesii_sales-tot_inv_amt .
lwa_download-scheme_code1 = lwa_minesii_sales-scheme_code1 .
lwa_download-gl_code1 = lwa_minesii_sales-gl_code1 .
lwa_download-amount1 = lwa_minesii_sales-amount1 .
lwa_download-scheme_code2 = lwa_minesii_sales-scheme_code2 .
lwa_download-gl_code2 = lwa_minesii_sales-gl_code2 .
lwa_download-amount2 = lwa_minesii_sales-amount2 .
lwa_download-scheme_code3 = lwa_minesii_sales-scheme_code3 .
lwa_download-gl_code3 = lwa_minesii_sales-gl_code3 .
lwa_download-amount3 = lwa_minesii_sales-amount3 .
lwa_download-scheme_code4 = lwa_minesii_sales-scheme_code4 .
lwa_download-gl_code4 = lwa_minesii_sales-gl_code4 .
lwa_download-amount4 = lwa_minesii_sales-amount4 .
lwa_download-scheme_code5 = lwa_minesii_sales-scheme_code5 .
lwa_download-gl_code5 = lwa_minesii_sales-gl_code5 .
lwa_download-amount5 = lwa_minesii_sales-amount5 .
lwa_download-scheme_code6 = lwa_minesii_sales-scheme_code6 .
lwa_download-gl_code6 = lwa_minesii_sales-gl_code6 .
lwa_download-amount6 = lwa_minesii_sales-amount6 .
lwa_download-scheme_code7 = lwa_minesii_sales-scheme_code7 .
lwa_download-gl_code7 = lwa_minesii_sales-gl_code7 .
lwa_download-amount7 = lwa_minesii_sales-amount7 .
lwa_download-scheme_code8 = lwa_minesii_sales-scheme_code8 .
lwa_download-gl_code8 = lwa_minesii_sales-gl_code8 .
lwa_download-amount8 = lwa_minesii_sales-amount8 .
lwa_download-scheme_code9 = lwa_minesii_sales-scheme_code9 .
lwa_download-gl_code9 = lwa_minesii_sales-gl_code9 .
lwa_download-amount9 = lwa_minesii_sales-amount9 .
lwa_download-scheme_code10 = lwa_minesii_sales-scheme_code10 .
lwa_download-gl_code10 = lwa_minesii_sales-gl_code10 .
lwa_download-amount10 = lwa_minesii_sales-amount10 .
lwa_download-user_id = lwa_minesii_sales-user_id .
lwa_download-time_stamp = lwa_minesii_sales-time_stamp .
append lwa_download to lt_download.
clear lwa_download.
*************
CLEAR:lwa_minesii-dr_amt,lwa_minesii-cr_amt.
READ TABLE lt_climscd INTO lwa_climscd WITH KEY unit_code = lwa_minesii_sales-unit_code
scheme_code = lwa_minesii_sales-scheme_code
div_code = '95'.
IF sy-subrc = 0.
lwa_minesii-counter = lwa_minesii-counter + 001.
lwa_minesii-unit_code = lwa_climscd-unit_code.
lwa_minesii-scheme_code = lwa_climscd-scheme_code.
lwa_minesii-div_code = lwa_climscd-div_code.
lwa_minesii-dr_amt = lwa_minesii_sales-tot_inv_amt.
lwa_minesii-kostl = lwa_climscd-kostl.
lwa_minesii-prof_cen = lwa_climscd-prof_cnt.
lwa_minesii-poskey = lc_dr.
lwa_minesii-invoice_no = lwa_minesii_sales-invoice_no.
lwa_minesii-qty = lwa_minesii_sales-qty.
lwa_minesii-party_code = lwa_minesii_sales-party_code.
lv_partycode = lwa_minesii_sales-party_code.
READ TABLE lt_kna1 INTO lwa_kna1 WITH KEY sortl = lv_partycode.
IF sy-subrc EQ 0.
lwa_minesii-gl_main_acct = lwa_kna1-kunnr.
ENDIF.
APPEND lwa_minesii TO lt_minesii.
CLEAR:lwa_minesii-gl_code,lv_glcode,lwa_minesii-dr_amt,lwa_minesii-gl_main_acct,lwa_minesii-dr_amt,
lwa_minesii-qty.
lwa_minesii-counter = lwa_minesii-counter.
lwa_minesii-unit_code = lwa_climscd-unit_code.
lwa_minesii-scheme_code = lwa_climscd-scheme_code.
lwa_minesii-div_code = lwa_climscd-div_code.
lwa_minesii-cr_amt = lwa_minesii_sales-prod_amt.
lwa_minesii-kostl = lwa_climscd-kostl.
lwa_minesii-prof_cen = lwa_climscd-prof_cnt.
lwa_minesii-poskey = lc_cr.
lwa_minesii-invoice_no = lwa_minesii_sales-invoice_no.
lwa_minesii-party_code = lwa_minesii_sales-party_code.
lwa_minesii-gl_code = lwa_minesii_sales-gl_code.
lv_glcode = lwa_minesii_sales-gl_code.
READ TABLE lt_skb1 INTO lwa_skb1 WITH KEY altkt = lv_glcode.
IF sy-subrc EQ 0.
lwa_minesii-gl_main_acct = lwa_skb1-saknr.
ENDIF.
APPEND lwa_minesii TO lt_minesii.
CLEAR:lwa_minesii-gl_code,lv_glcode,lwa_minesii-cr_amt,lwa_minesii-gl_main_acct,lwa_minesii-cr_amt.
IF lwa_minesii_sales-gl_code1 IS NOT INITIAL AND
lwa_minesii_sales-scheme_code1 IS NOT INITIAL AND
lwa_minesii_sales-amount1 NE '.00'.
lwa_minesii-counter = lwa_minesii-counter.
lwa_minesii-unit_code = lwa_climscd-unit_code.
lwa_minesii-scheme_code = lwa_climscd-scheme_code.
lwa_minesii-div_code = lwa_climscd-div_code.
lwa_minesii-cr_amt = lwa_minesii_sales-amount1.
lwa_minesii-kostl = lwa_climscd-kostl.
lwa_minesii-prof_cen = lwa_climscd-prof_cnt.
lwa_minesii-poskey = lc_cr.
lwa_minesii-invoice_no = lwa_minesii_sales-invoice_no.
lwa_minesii-party_code = lwa_minesii_sales-party_code.
lwa_minesii-gl_code = lwa_minesii_sales-gl_code1.
lv_glcode = lwa_minesii_sales-gl_code1.
READ TABLE lt_skb1 INTO lwa_skb1 WITH KEY altkt = lv_glcode.
IF sy-subrc EQ 0.
lwa_minesii-gl_main_acct = lwa_skb1-saknr.
ENDIF.
APPEND lwa_minesii TO lt_minesii.
CLEAR:lwa_minesii-gl_code,lv_glcode,lwa_minesii-cr_amt,lwa_minesii-gl_main_acct,lwa_minesii-cr_amt.
ENDIF.
IF lwa_minesii_sales-gl_code2 IS NOT INITIAL AND
lwa_minesii_sales-scheme_code2 IS NOT INITIAL AND
lwa_minesii_sales-amount2 NE '.00'.
lwa_minesii-counter = lwa_minesii-counter.
lwa_minesii-unit_code = lwa_climscd-unit_code.
lwa_minesii-scheme_code = lwa_climscd-scheme_code.
lwa_minesii-div_code = lwa_climscd-div_code.
lwa_minesii-cr_amt = lwa_minesii_sales-amount2.
lwa_minesii-kostl = lwa_climscd-kostl.
lwa_minesii-prof_cen = lwa_climscd-prof_cnt.
lwa_minesii-poskey = lc_cr.
lwa_minesii-invoice_no = lwa_minesii_sales-invoice_no.
lwa_minesii-party_code = lwa_minesii_sales-party_code.
lwa_minesii-gl_code = lwa_minesii_sales-gl_code2.
lv_glcode = lwa_minesii_sales-gl_code2.
READ TABLE lt_skb1 INTO lwa_skb1 WITH KEY altkt = lv_glcode.
IF sy-subrc EQ 0.
lwa_minesii-gl_main_acct = lwa_skb1-saknr.
ENDIF.
APPEND lwa_minesii TO lt_minesii.
CLEAR:lwa_minesii-gl_code,lv_glcode,lwa_minesii-cr_amt,lwa_minesii-gl_main_acct,lwa_minesii-cr_amt.
ENDIF.
IF lwa_minesii_sales-gl_code3 IS NOT INITIAL AND
lwa_minesii_sales-scheme_code3 IS NOT INITIAL AND
lwa_minesii_sales-amount3 NE '.00'.
lwa_minesii-counter = lwa_minesii-counter.
lwa_minesii-unit_code = lwa_climscd-unit_code.
lwa_minesii-scheme_code = lwa_climscd-scheme_code.
lwa_minesii-div_code = lwa_climscd-div_code.
lwa_minesii-cr_amt = lwa_minesii_sales-amount3.
lwa_minesii-kostl = lwa_climscd-kostl.
lwa_minesii-prof_cen = lwa_climscd-prof_cnt.
lwa_minesii-poskey = lc_cr.
lwa_minesii-invoice_no = lwa_minesii_sales-invoice_no.
lwa_minesii-party_code = lwa_minesii_sales-party_code.
lwa_minesii-gl_code = lwa_minesii_sales-gl_code3.
lv_glcode = lwa_minesii_sales-gl_code3.
READ TABLE lt_skb1 INTO lwa_skb1 WITH KEY altkt = lv_glcode.
IF sy-subrc EQ 0.
lwa_minesii-gl_main_acct = lwa_skb1-saknr.
ENDIF.
APPEND lwa_minesii TO lt_minesii.
CLEAR:lwa_minesii-gl_code,lv_glcode,lwa_minesii-cr_amt,lwa_minesii-gl_main_acct,lwa_minesii-cr_amt.
ENDIF.
IF lwa_minesii_sales-gl_code4 IS NOT INITIAL AND
lwa_minesii_sales-scheme_code4 IS NOT INITIAL AND
lwa_minesii_sales-amount4 NE '.00'.
lwa_minesii-counter = lwa_minesii-counter.
lwa_minesii-unit_code = lwa_climscd-unit_code.
lwa_minesii-scheme_code = lwa_climscd-scheme_code.
lwa_minesii-div_code = lwa_climscd-div_code.
lwa_minesii-cr_amt = lwa_minesii_sales-amount4.
lwa_minesii-kostl = lwa_climscd-kostl.
lwa_minesii-prof_cen = lwa_climscd-prof_cnt.
lwa_minesii-poskey = lc_cr.
lwa_minesii-invoice_no = lwa_minesii_sales-invoice_no.
lwa_minesii-party_code = lwa_minesii_sales-party_code.
lwa_minesii-gl_code = lwa_minesii_sales-gl_code4.
lv_glcode = lwa_minesii_sales-gl_code4.
READ TABLE lt_skb1 INTO lwa_skb1 WITH KEY altkt = lv_glcode.
IF sy-subrc EQ 0.
lwa_minesii-gl_main_acct = lwa_skb1-saknr.
ENDIF.
APPEND lwa_minesii TO lt_minesii.
CLEAR:lwa_minesii-gl_code,lv_glcode,lwa_minesii-cr_amt,lwa_minesii-gl_main_acct,lwa_minesii-cr_amt.
ENDIF.
IF lwa_minesii_sales-gl_code5 IS NOT INITIAL AND
lwa_minesii_sales-scheme_code5 IS NOT INITIAL AND
lwa_minesii_sales-amount5 NE '.00'.
lwa_minesii-counter = lwa_minesii-counter.
lwa_minesii-unit_code = lwa_climscd-unit_code.
lwa_minesii-scheme_code = lwa_climscd-scheme_code.
lwa_minesii-div_code = lwa_climscd-div_code.
lwa_minesii-cr_amt = lwa_minesii_sales-amount5.
lwa_minesii-kostl = lwa_climscd-kostl.
lwa_minesii-prof_cen = lwa_climscd-prof_cnt.
lwa_minesii-poskey = lc_cr.
lwa_minesii-invoice_no = lwa_minesii_sales-invoice_no.
lwa_minesii-party_code = lwa_minesii_sales-party_code.
lwa_minesii-gl_code = lwa_minesii_sales-gl_code5.
lv_glcode = lwa_minesii_sales-gl_code5.
READ TABLE lt_skb1 INTO lwa_skb1 WITH KEY altkt = lv_glcode.
IF sy-subrc EQ 0.
lwa_minesii-gl_main_acct = lwa_skb1-saknr.
ENDIF.
APPEND lwa_minesii TO lt_minesii.
CLEAR:lwa_minesii-gl_code,lv_glcode,lwa_minesii-cr_amt,lwa_minesii-gl_main_acct,lwa_minesii-cr_amt.
ENDIF.
IF lwa_minesii_sales-gl_code6 IS NOT INITIAL AND
lwa_minesii_sales-scheme_code6 IS NOT INITIAL AND
lwa_minesii_sales-amount6 NE '.00'.
lwa_minesii-counter = lwa_minesii-counter.
lwa_minesii-unit_code = lwa_climscd-unit_code.
lwa_minesii-scheme_code = lwa_climscd-scheme_code.
lwa_minesii-div_code = lwa_climscd-div_code.
lwa_minesii-cr_amt = lwa_minesii_sales-amount6.
lwa_minesii-kostl = lwa_climscd-kostl.
lwa_minesii-prof_cen = lwa_climscd-prof_cnt.
lwa_minesii-poskey = lc_cr.
lwa_minesii-invoice_no = lwa_minesii_sales-invoice_no.
lwa_minesii-party_code = lwa_minesii_sales-party_code.
lwa_minesii-gl_code = lwa_minesii_sales-gl_code6.
lv_glcode = lwa_minesii_sales-gl_code6.
READ TABLE lt_skb1 INTO lwa_skb1 WITH KEY altkt = lv_glcode.
IF sy-subrc EQ 0.
lwa_minesii-gl_main_acct = lwa_skb1-saknr.
ENDIF.
APPEND lwa_minesii TO lt_minesii.
CLEAR:lwa_minesii-gl_code,lv_glcode,lwa_minesii-cr_amt,lwa_minesii-gl_main_acct,lwa_minesii-cr_amt.
ENDIF.
IF lwa_minesii_sales-gl_code7 IS NOT INITIAL AND
lwa_minesii_sales-scheme_code7 IS NOT INITIAL AND
lwa_minesii_sales-amount7 NE '.00'.
lwa_minesii-counter = lwa_minesii-counter.
lwa_minesii-unit_code = lwa_climscd-unit_code.
lwa_minesii-scheme_code = lwa_climscd-scheme_code.
lwa_minesii-div_code = lwa_climscd-div_code.
lwa_minesii-cr_amt = lwa_minesii_sales-amount7.
lwa_minesii-kostl = lwa_climscd-kostl.
lwa_minesii-prof_cen = lwa_climscd-prof_cnt.
lwa_minesii-poskey = lc_cr.
lwa_minesii-invoice_no = lwa_minesii_sales-invoice_no.
lwa_minesii-party_code = lwa_minesii_sales-party_code.
lwa_minesii-gl_code = lwa_minesii_sales-gl_code7.
lv_glcode = lwa_minesii_sales-gl_code7.
READ TABLE lt_skb1 INTO lwa_skb1 WITH KEY altkt = lv_glcode.
IF sy-subrc EQ 0.
lwa_minesii-gl_main_acct = lwa_skb1-saknr.
ENDIF.
APPEND lwa_minesii TO lt_minesii.
CLEAR:lwa_minesii-gl_code,lv_glcode,lwa_minesii-cr_amt,lwa_minesii-gl_main_acct,lwa_minesii-cr_amt.
ENDIF.
IF lwa_minesii_sales-gl_code8 IS NOT INITIAL AND
lwa_minesii_sales-scheme_code8 IS NOT INITIAL AND
lwa_minesii_sales-amount8 NE '.00'.
lwa_minesii-counter = lwa_minesii-counter.
lwa_minesii-unit_code = lwa_climscd-unit_code.
lwa_minesii-scheme_code = lwa_climscd-scheme_code.
lwa_minesii-div_code = lwa_climscd-div_code.
lwa_minesii-cr_amt = lwa_minesii_sales-amount8.
lwa_minesii-kostl = lwa_climscd-kostl.
lwa_minesii-prof_cen = lwa_climscd-prof_cnt.
lwa_minesii-poskey = lc_cr.
lwa_minesii-invoice_no = lwa_minesii_sales-invoice_no.
lwa_minesii-party_code = lwa_minesii_sales-party_code.
lwa_minesii-gl_code = lwa_minesii_sales-gl_code8.
lv_glcode = lwa_minesii_sales-gl_code8.
READ TABLE lt_skb1 INTO lwa_skb1 WITH KEY altkt = lv_glcode.
IF sy-subrc EQ 0.
lwa_minesii-gl_main_acct = lwa_skb1-saknr.
ENDIF.
APPEND lwa_minesii TO lt_minesii.
CLEAR:lwa_minesii-gl_code,lv_glcode,lwa_minesii-cr_amt,lwa_minesii-gl_main_acct,lwa_minesii-cr_amt.
ENDIF.
IF lwa_minesii_sales-gl_code9 IS NOT INITIAL AND
lwa_minesii_sales-scheme_code9 IS NOT INITIAL AND
lwa_minesii_sales-amount9 NE '.00'.
lwa_minesii-counter = lwa_minesii-counter.
lwa_minesii-unit_code = lwa_climscd-unit_code.
lwa_minesii-scheme_code = lwa_climscd-scheme_code.
lwa_minesii-div_code = lwa_climscd-div_code.
lwa_minesii-cr_amt = lwa_minesii_sales-amount9.
lwa_minesii-kostl = lwa_climscd-kostl.
lwa_minesii-prof_cen = lwa_climscd-prof_cnt.
lwa_minesii-poskey = lc_cr.
lwa_minesii-invoice_no = lwa_minesii_sales-invoice_no.
lwa_minesii-party_code = lwa_minesii_sales-party_code.
lwa_minesii-gl_code = lwa_minesii_sales-gl_code9.
lv_glcode = lwa_minesii_sales-gl_code9.
READ TABLE lt_skb1 INTO lwa_skb1 WITH KEY altkt = lv_glcode.
IF sy-subrc EQ 0.
lwa_minesii-gl_main_acct = lwa_skb1-saknr.
ENDIF.
APPEND lwa_minesii TO lt_minesii.
CLEAR:lwa_minesii-gl_code,lv_glcode,lwa_minesii-cr_amt,lwa_minesii-gl_main_acct,lwa_minesii-cr_amt.
ENDIF.
IF lwa_minesii_sales-gl_code10 IS NOT INITIAL AND
lwa_minesii_sales-scheme_code10 IS NOT INITIAL AND
lwa_minesii_sales-amount10 NE '.00'.
lwa_minesii-counter = lwa_minesii-counter.
lwa_minesii-unit_code = lwa_climscd-unit_code.
lwa_minesii-scheme_code = lwa_climscd-scheme_code.
lwa_minesii-div_code = lwa_climscd-div_code.
lwa_minesii-cr_amt = lwa_minesii_sales-amount10.
lwa_minesii-kostl = lwa_climscd-kostl.
lwa_minesii-prof_cen = lwa_climscd-prof_cnt.
lwa_minesii-poskey = lc_cr.
lwa_minesii-invoice_no = lwa_minesii_sales-invoice_no.
lwa_minesii-party_code = lwa_minesii_sales-party_code.
lwa_minesii-gl_code = lwa_minesii_sales-gl_code10.
lv_glcode = lwa_minesii_sales-gl_code10.
READ TABLE lt_skb1 INTO lwa_skb1 WITH KEY altkt = lv_glcode.
IF sy-subrc EQ 0.
lwa_minesii-gl_main_acct = lwa_skb1-saknr.
ENDIF.
APPEND lwa_minesii TO lt_minesii.
CLEAR:lwa_minesii-gl_code,lv_glcode,lwa_minesii-cr_amt,lwa_minesii-gl_main_acct,lwa_minesii-cr_amt.
ENDIF.
**Validation checking for debit & credit for every invoice before posting
CLEAR:lv_debit,lv_credit,lv_difamt,lv_amount_cr,lv_amount_dr.
LOOP AT lt_minesii INTO lwa_minesii WHERE invoice_no = lwa_minesii-invoice_no.
lv_debit = lv_debit + lwa_minesii-dr_amt.
lv_credit = lv_credit + lwa_minesii-cr_amt.
ENDLOOP.
IF lv_credit EQ lv_debit.
*
ELSE.
lwa_elog-invoice_no = lwa_minesii-invoice_no.
CONCATENATE'Invoice' lwa_elog-invoice_no 'not Posted because of Credit/Debit Missmatch' INTO
lwa_elog-inv_mesg SEPARATED BY space.
APPEND lwa_elog TO lt_elog.
DELETE lt_minesii WHERE invoice_no = lwa_elog-invoice_no.
CLEAR lwa_elog.
ENDIF.
ELSEIF sy-subrc NE 0.
lwa_elog-invoice_no = lwa_minesii_sales-invoice_no.
CONCATENATE 'Unit Code' lwa_minesii_sales-unit_code
'Scheme Code' lwa_minesii_sales-scheme_code 'Division Code' '95'
'Combination not maintained in table'
INTO lwa_elog-inv_mesg SEPARATED BY space.
APPEND lwa_elog TO lt_elog.
CLEAR lwa_elog.
* LV_ERROR = 'X'.
* EXIT.
ENDIF.
* CLEAR:LWA_MINESII.
* ENDIF.
* DELETE LT_MINESII WHERE CR_AMT EQ '0' AND DR_AMT NE '0'.
ENDLOOP.
******* DOWNLOAD EXCEL
**First Download
IF sy-mandt+0(1) = '2'.
CONCATENATE 'C:\INTERFACES\MINEII\DEV\SAP_MINEII' sy-mandt sy-datum '.XLS' INTO lv_path.
ELSEIF sy-mandt+0(1) = '3'.
CONCATENATE 'C:\INTERFACES\MINEII\QTY\SAP_MINEII' sy-mandt sy-datum '.XLS' INTO lv_path.
ELSEIF sy-mandt+0(1) = '4'.
CONCATENATE 'C:\INTERFACES\MINEII\PRD\SAP_MINEII' sy-mandt sy-datum '.XLS' INTO lv_path.
ENDIF.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = lv_path
filetype = 'ASC'
write_field_separator = 'X'
CHANGING
data_tab = lt_download
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
not_supported_by_gui = 22
error_no_gui = 23
OTHERS = 24.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
*******
DELETE FROM zfi_minesiielog.
COMMIT WORK.
IF lt_elog IS NOT INITIAL.
INSERT zfi_minesiielog FROM TABLE lt_elog.
IF sy-subrc EQ 0.
COMMIT WORK.
ENDIF.
ENDIF.
IF lt_elog IS INITIAL.
CALL FUNCTION 'ZFI_INTERFACE_MINESII'
TABLES
lt_minesii = lt_minesii[]
lt_elog = lt_elog[].
**Getting Success and Failure messages from BDC
REFRESH lt_suc_message[].
REFRESH lt_fail_message[].
IMPORT lt_suc_message TO lt_suc_message[] FROM MEMORY ID 'SUCCESS'.
IMPORT lt_fail_message TO lt_fail_message[] FROM MEMORY ID 'FAIL'.
***logic for mail
DATA lv_str(30).
DATA lv_str1(30).
lv_str = 'Posted Successfully'.
lv_str1 = 'Posting Failed'.
LOOP AT lt_suc_message INTO wa_suc_message.
wa_suc_message1-mandt = sy-mandt.
wa_suc_message1-message = wa_suc_message-l_mstring.
CONCATENATE wa_suc_message1-message lv_str INTO wa_suc_message1-message SEPARATED BY space.
APPEND wa_suc_message1 TO lt_suc_message1.
CLEAR:wa_suc_message1,wa_suc_message.
ENDLOOP.
SORT lt_suc_message1 ASCENDING BY mandt message.
DELETE ADJACENT DUPLICATES FROM lt_suc_message1 COMPARING mandt message.
LOOP AT lt_fail_message INTO wa_fail_message.
wa_fail_message1-mandt = sy-mandt.
wa_fail_message1-message = wa_fail_message-l_mstring.
CONCATENATE wa_fail_message1-message lv_str1 INTO wa_fail_message1-message SEPARATED BY space.
APPEND wa_fail_message1 TO lt_fail_message1.
CLEAR:wa_fail_message1,wa_fail_message.
ENDLOOP.
SORT lt_fail_message1 ASCENDING BY mandt message.
DELETE ADJACENT DUPLICATES FROM lt_fail_message1 COMPARING mandt message.
IF lt_suc_message1[] IS NOT INITIAL.
CALL FUNCTION 'ZSEND_MAIL_MINEII'
TABLES
lt_mail = lt_suc_message1[].
ENDIF.
IF lt_fail_message1[] IS NOT INITIAL.
CALL FUNCTION 'ZSEND_MAIL_MINEII'
TABLES
lt_mail = lt_fail_message1[].
ENDIF.
ENDIF.
ENDIF. "for error log (Non-availability of party code)
ENDMETHOD.
***************************************************************
Custom Function module for posting
***************************************************************
FUNCTION ZFI_INTERFACE_MINESII.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(CTU) LIKE APQI-PUTACTIVE DEFAULT 'X'
*" VALUE(MODE) LIKE APQI-PUTACTIVE DEFAULT 'N'
*" VALUE(UPDATE) LIKE APQI-PUTACTIVE DEFAULT 'L'
*" VALUE(GROUP) LIKE APQI-GROUPID OPTIONAL
*" VALUE(USER) LIKE APQI-USERID OPTIONAL
*" VALUE(KEEP) LIKE APQI-QERASE OPTIONAL
*" VALUE(HOLDDATE) LIKE APQI-STARTDATE OPTIONAL
*" VALUE(NODATA) LIKE APQI-PUTACTIVE DEFAULT '/'
*" VALUE(BLDAT_001) LIKE BDCDATA-FVAL DEFAULT '02.09.2014'
*" VALUE(BLART_002) LIKE BDCDATA-FVAL DEFAULT 'sa'
*" VALUE(BUKRS_003) LIKE BDCDATA-FVAL DEFAULT '1000'
*" VALUE(BUDAT_004) LIKE BDCDATA-FVAL DEFAULT '12.09.2014'
*" VALUE(MONAT_005) LIKE BDCDATA-FVAL DEFAULT '10'
*" VALUE(WAERS_006) LIKE BDCDATA-FVAL DEFAULT 'inr'
*" VALUE(XBLNR_007) LIKE BDCDATA-FVAL DEFAULT 'Upload'
*" VALUE(BKTXT_008) LIKE BDCDATA-FVAL DEFAULT 'MINESII Sales'
*" VALUE(DOCID_009) LIKE BDCDATA-FVAL DEFAULT '*'
*" VALUE(NEWBS_010) LIKE BDCDATA-FVAL DEFAULT '40'
*" VALUE(NEWKO_011) LIKE BDCDATA-FVAL DEFAULT '4025100301'
*" VALUE(WRBTR_012) LIKE BDCDATA-FVAL DEFAULT '1000'
*" VALUE(BUPLA_013) LIKE BDCDATA-FVAL DEFAULT 'M00I'
*" VALUE(ZUONR_016) LIKE BDCDATA-FVAL DEFAULT 'upld'
*" VALUE(SGTXT_017) LIKE BDCDATA-FVAL DEFAULT 'olimmslwdger'
*" VALUE(FMORE_018) LIKE BDCDATA-FVAL DEFAULT 'X'
*" VALUE(WRBTR_020) LIKE BDCDATA-FVAL DEFAULT '1000'
*" VALUE(BUPLA_021) LIKE BDCDATA-FVAL DEFAULT 'M00I'
*" VALUE(ZUONR_024) LIKE BDCDATA-FVAL DEFAULT 'upld'
*" VALUE(SGTXT_025) LIKE BDCDATA-FVAL DEFAULT 'olimmslwdger'
*" VALUE(NEWBS_026) LIKE BDCDATA-FVAL DEFAULT '50'
*" VALUE(NEWKO_027) LIKE BDCDATA-FVAL DEFAULT '2220030122'
*" VALUE(FMORE_028) LIKE BDCDATA-FVAL DEFAULT 'X'
*" VALUE(KOSTL_029) LIKE BDCDATA-FVAL DEFAULT 'M010010102'
*" VALUE(PRCTR_030) LIKE BDCDATA-FVAL DEFAULT 'M01002'
*" VALUE(GEBER_031) LIKE BDCDATA-FVAL DEFAULT 'INT-ACCRUL'
*" VALUE(FIPEX_032) LIKE BDCDATA-FVAL DEFAULT 'NONBUDGET'
*" VALUE(FISTL_033) LIKE BDCDATA-FVAL DEFAULT 'M010010102'
*" VALUE(FIPOS_034) LIKE BDCDATA-FVAL DEFAULT 'NONBUDGET'
*" VALUE(WRBTR_035) LIKE BDCDATA-FVAL DEFAULT '1000'
*" VALUE(BUPLA_036) LIKE BDCDATA-FVAL DEFAULT 'M00I'
*" VALUE(ZUONR_039) LIKE BDCDATA-FVAL DEFAULT 'upld'
*" VALUE(SGTXT_040) LIKE BDCDATA-FVAL DEFAULT 'olimmslwdger'
*" VALUE(FMORE_041) LIKE BDCDATA-FVAL DEFAULT 'X'
*" VALUE(PRCTR_042) LIKE BDCDATA-FVAL DEFAULT 'M01001'
*" VALUE(WRBTR_043) LIKE BDCDATA-FVAL DEFAULT '1000'
*" VALUE(BUPLA_044) LIKE BDCDATA-FVAL DEFAULT 'M00I'
*" VALUE(ZUONR_047) LIKE BDCDATA-FVAL DEFAULT 'upld'
*" VALUE(SGTXT_048) LIKE BDCDATA-FVAL DEFAULT 'olimmslwdger'
*" VALUE(NEWBS_049) LIKE BDCDATA-FVAL DEFAULT '40'
*" VALUE(NEWKO_050) LIKE BDCDATA-FVAL DEFAULT '1015060101'
*" VALUE(FMORE_051) LIKE BDCDATA-FVAL DEFAULT 'X'
*" VALUE(PRCTR_052) LIKE BDCDATA-FVAL DEFAULT 'M01001'
*" VALUE(FIPEX_053) LIKE BDCDATA-FVAL DEFAULT 'BALANCESHEET'
*" VALUE(FIPOS_054) LIKE BDCDATA-FVAL DEFAULT 'BALANCESHEET'
*" VALUE(WRBTR_055) LIKE BDCDATA-FVAL DEFAULT '1000'
*" VALUE(BUPLA_056) LIKE BDCDATA-FVAL DEFAULT 'M00I'
*" VALUE(ZUONR_059) LIKE BDCDATA-FVAL DEFAULT 'upld'
*" VALUE(SGTXT_060) LIKE BDCDATA-FVAL DEFAULT 'olimmslwdger'
*" VALUE(FMORE_061) LIKE BDCDATA-FVAL DEFAULT 'X'
*" VALUE(PRCTR_062) LIKE BDCDATA-FVAL DEFAULT 'M01001'
*" VALUE(WRBTR_063) LIKE BDCDATA-FVAL DEFAULT '1000'
*" VALUE(BUPLA_064) LIKE BDCDATA-FVAL DEFAULT 'M00I'
*" VALUE(ZUONR_067) LIKE BDCDATA-FVAL DEFAULT 'upld'
*" VALUE(SGTXT_068) LIKE BDCDATA-FVAL DEFAULT 'olimmslwdger'
*" VALUE(NEWBS_069) LIKE BDCDATA-FVAL DEFAULT '50'
*" VALUE(NEWKO_070) LIKE BDCDATA-FVAL DEFAULT '3005030203'
*" VALUE(FMORE_071) LIKE BDCDATA-FVAL DEFAULT 'X'
*" VALUE(PRCTR_072) LIKE BDCDATA-FVAL DEFAULT 'M01001'
*" VALUE(GEBER_073) LIKE BDCDATA-FVAL DEFAULT 'INT-ACCRUL'
*" VALUE(FIPEX_074) LIKE BDCDATA-FVAL DEFAULT 'BALANCESHEET'
*" VALUE(FIPOS_075) LIKE BDCDATA-FVAL DEFAULT 'BALANCESHEET'
*" VALUE(WRBTR_076) LIKE BDCDATA-FVAL DEFAULT '1000'
*" VALUE(BUPLA_077) LIKE BDCDATA-FVAL DEFAULT 'M00I'
*" VALUE(ZUONR_080) LIKE BDCDATA-FVAL DEFAULT 'upld'
*" VALUE(SGTXT_081) LIKE BDCDATA-FVAL DEFAULT 'olimmslwdger'
*" VALUE(FMORE_082) LIKE BDCDATA-FVAL DEFAULT 'X'
*" VALUE(PRCTR_083) LIKE BDCDATA-FVAL DEFAULT 'M01001'
*" VALUE(WRBTR_084) LIKE BDCDATA-FVAL DEFAULT '1000'
*" VALUE(BUPLA_085) LIKE BDCDATA-FVAL DEFAULT 'M00I'
*" VALUE(ZUONR_088) LIKE BDCDATA-FVAL DEFAULT 'upld'
*" VALUE(SGTXT_089) LIKE BDCDATA-FVAL DEFAULT 'olimmslwdger'
*" VALUE(FMORE_090) LIKE BDCDATA-FVAL DEFAULT 'X'
*" VALUE(PRCTR_091) LIKE BDCDATA-FVAL DEFAULT 'M01001'
*" VALUE(GEBER_092) LIKE BDCDATA-FVAL DEFAULT 'INT-ACCRUL'
*" VALUE(FIPEX_093) LIKE BDCDATA-FVAL DEFAULT 'NONBUDGET'
*" VALUE(FIPOS_094) LIKE BDCDATA-FVAL DEFAULT 'NONBUDGET'
*" EXPORTING
*" VALUE(SUBRC) LIKE SYST-SUBRC
*" TABLES
*" MESSTAB STRUCTURE BDCMSGCOLL OPTIONAL
*" LT_MINESII STRUCTURE ZFI_MINESII
*" LT_ELOG STRUCTURE ZFI_MINESIIELOG
*"----------------------------------------------------------------------
BREAK-POINT.
DATA :LWA_MINESII LIKE LT_MINESII,
LWA_MINESII_TEMP LIKE LT_MINESII.
DATA LT_MINESII_TEMP TYPE TABLE OF ZFI_MINESII.
DATA: LV_COUNTER TYPE CHAR1,
LV_AMT TYPE BDC_FVAL,
LV_INC TYPE I,
LV_DATUM(10) TYPE C,
lv_qty TYPE BDC_FVAL.
* COUNTER TYPE CHAR1.
CONSTANTS:
LC_AMT(15) TYPE C VALUE SPACE,
LC_DCTYP TYPE BDC_FVAL VALUE 'M1',"'ZI',
LC_BUKRS TYPE BDC_FVAL VALUE '1000',
LC_WAERS TYPE BDC_FVAL VALUE 'INR',
LC_ZUONR TYPE BDC_FVAL VALUE 'MINESII SALES',
LC_SGTXT TYPE BDC_FVAL VALUE 'MINESII SALES'.
* LV_COUNTER = 1.
LV_INC = 1.
LT_MINESII_TEMP[] = LT_MINESII[].
LOOP AT LT_MINESII INTO LWA_MINESII.
* clear:lv_qty.
if lwa_minesii-poskey = '01'.
lv_qty = LWA_MINESII-qty.
endif.
IF LWA_MINESII-CR_AMT NE LC_AMT.
LV_AMT = LWA_MINESII-CR_AMT.
ELSEIF LWA_MINESII-DR_AMT NE LC_AMT.
LV_AMT = LWA_MINESII-DR_AMT.
ENDIF.
CONCATENATE SY-DATUM+6(2) '.'
SY-DATUM+4(2) '.'
SY-DATUM+0(4) INTO LV_DATUM.
SUBRC = 0.
**************Processing of Header Record for the first time*******************
ON CHANGE OF LWA_MINESII-COUNTER.
PERFORM BDC_NODATA USING NODATA.
PERFORM OPEN_GROUP USING GROUP USER KEEP HOLDDATE CTU.
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'
LV_DATUM."BLDAT_001.
PERFORM BDC_FIELD USING 'BKPF-BLART'
LC_DCTYP."BLART_002.
PERFORM BDC_FIELD USING 'BKPF-BUKRS'
LC_BUKRS."BUKRS_003.
PERFORM BDC_FIELD USING 'BKPF-BUDAT'
LV_DATUM."BUDAT_004.
PERFORM BDC_FIELD USING 'BKPF-MONAT'
MONAT_005.
PERFORM BDC_FIELD USING 'BKPF-WAERS'
LC_WAERS."WAERS_006.
PERFORM BDC_FIELD USING 'BKPF-XBLNR'
LWA_MINESII-INVOICE_NO."XBLNR_007.
PERFORM BDC_FIELD USING 'BKPF-BKTXT'
BKTXT_008.
PERFORM BDC_FIELD USING 'FS006-DOCID'
DOCID_009.
PERFORM BDC_FIELD USING 'RF05A-NEWBS'
LWA_MINESII-POSKEY."NEWBS_010.
PERFORM BDC_FIELD USING 'RF05A-NEWKO'
LWA_MINESII-GL_MAIN_ACCT."NEWKO_011.
ENDON.
* BREAK-POINT.
******************End of header Record*******************************************
IF LWA_MINESII-POSKEY = '50'.
***********Processing of Next Screens**********************************************
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'
LV_AMT."WRBTR_012.
PERFORM BDC_FIELD USING 'BSEG-BUPLA'
BUPLA_013.
if lwa_minesII-gl_code = '6531'.
PERFORM BDC_FIELD USING 'BSEG-MENGE'
lv_qty.
PERFORM BDC_FIELD USING 'BSEG-MEINS'
'TO'."MEINS_015.
endif.
PERFORM BDC_FIELD USING 'BSEG-ZUONR'
LC_ZUONR."ZUONR_016.
PERFORM BDC_FIELD USING 'BSEG-SGTXT'
LC_SGTXT."SGTXT_017.
PERFORM BDC_FIELD USING 'DKACB-FMORE'
FMORE_018.
***
PERFORM BDC_DYNPRO USING 'SAPLKACB' '0002'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'COBL-KOSTL'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTE'.
* PERFORM BDC_FIELD USING 'COBL-KOSTL'
* LWA_MINESII-KOSTL."KOSTL_019.
PERFORM BDC_FIELD USING 'COBL-PRCTR'
LWA_MINESII-PROF_CEN."KOSTL_019.
* PERFORM BDC_FIELD USING 'COBL-FIPEX'
* 'NONBUDGET'.
***********End Of screens***********************************************************
LV_INC = LV_INC + 1.
*********after all the items are processed posting being done in F-02*********
AT END OF COUNTER.
PERFORM BDC_DYNPRO USING 'SAPMF05A' '0300'. "300 ABHINAV
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BU'.
PERFORM BDC_DYNPRO USING 'SAPLKACB' '0002'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTE'.
PERFORM BDC_DYNPRO USING 'SAPMF05A' '0700'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RF05A-NEWBS'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BU'.
PERFORM BDC_TRANSACTION TABLES MESSTAB
USING 'F-02'
CTU
MODE
UPDATE.
* BREAK-POINT.
IF SY-SUBRC <> 0.
SUBRC = SY-SUBRC.
EXIT.
ENDIF.
PERFORM CLOSE_GROUP USING CTU.
CONTINUE.
ENDAT.
***************End of posting*****************************
************Reading next line item form the Temp. Internal table for Posting key and G/L Acct.
PERFORM BDC_DYNPRO USING 'SAPMF05A' '0300'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
READ TABLE LT_MINESII_TEMP INTO LWA_MINESII_TEMP INDEX LV_INC.
IF SY-SUBRC = 0.
PERFORM BDC_FIELD USING 'RF05A-NEWBS'
LWA_MINESII_TEMP-POSKEY.
PERFORM BDC_FIELD USING 'RF05A-NEWKO'
LWA_MINESII_TEMP-GL_MAIN_ACCT.
** PERFORM BDC_FIELD USING 'RF05A-NEWUM'
** GFS_RECORD-NEWUM.
ENDIF.
PERFORM BDC_DYNPRO USING 'SAPLKACB' '0002'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTE'.
* NEWBS = GFS_RECORD-NEWBS.
CLEAR:LWA_MINESII_TEMP.
CONTINUE.
*************end of reading next line item**************************************
ENDIF.
IF LWA_MINESII-POSKEY = '01'.
PERFORM BDC_DYNPRO USING 'SAPMF05A' '0301'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RF05A-NEWKO'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
* PERFORM BDC_FIELD USING 'BSEG-HKONT'
* GFS_RECORD-HKONT."'2215010101'.
PERFORM BDC_FIELD USING 'BSEG-WRBTR'
LV_AMT."'1000'.
* PERFORM BDC_FIELD USING 'BSEG-MWSKZ'
* '**'.
* PERFORM BDC_FIELD USING 'BSEG-ZTERM'
* GFS_RECORD-ZTERM."'0001'.
PERFORM BDC_FIELD USING 'BSEG-ZFBDT'
LV_DATUM."result."GFS_RECORD-BUDAT."'12.11.2014'.
PERFORM BDC_FIELD USING 'BSEG-ZUONR'
LC_ZUONR."'JJJJJ'.
PERFORM BDC_FIELD USING 'BSEG-SGTXT'
LC_SGTXT."'FFFF'.
LV_INC = LV_INC + 1.
AT END OF COUNTER.
PERFORM BDC_DYNPRO USING 'SAPMF05A' '0301'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BS'.
*BREAK-POINT.
PERFORM BDC_TRANSACTION TABLES MESSTAB
USING 'F-02'
CTU
MODE
UPDATE.
* BREAK-POINT.
IF SY-SUBRC <> 0.
SUBRC = SY-SUBRC.
EXIT.
ENDIF.
PERFORM CLOSE_GROUP USING CTU.
CONTINUE.
ENDAT.
READ TABLE LT_MINESII_TEMP INTO LWA_MINESII_TEMP INDEX LV_INC.
IF SY-SUBRC = 0.
PERFORM BDC_FIELD USING 'RF05A-NEWBS'
LWA_MINESII_TEMP-POSKEY.
PERFORM BDC_FIELD USING 'RF05A-NEWKO'
LWA_MINESII_TEMP-GL_MAIN_ACCT.
** PERFORM BDC_FIELD USING 'RF05A-NEWUM'
** GFS_RECORD-NEWUM.
* PERFORM BDC_FIELD USING 'RF05A-NEWUM'
* GFS_RECORD-NEWUM_012(001).
ENDIF.
CONTINUE.
ENDIF.
ENDLOOP.
**DATA LT_MESSTAB TYPE STANDARD TABLE OF BDCMSGCOLL.
** LT_MESSTAB[] = messtab[].
* BREAK-POINT.
FREE MEMORY ID 'SUCCESS'.
FREE MEMORY ID 'FAIL'.
refresh lt_suc_message[].
refresh lt_fail_message[].
TABLES T100.
LOOP AT MESSTAB WHERE MSGTYP = 'S'.
SELECT SINGLE * FROM T100 WHERE SPRSL = MESSTAB-MSGSPRA
AND ARBGB = MESSTAB-MSGID
AND MSGNR = MESSTAB-MSGNR.
IF SY-SUBRC = 0.
L_MSTRING = T100-TEXT.
IF L_MSTRING CS '&1'.
REPLACE '&1' WITH MESSTAB-MSGV1 INTO L_MSTRING.
REPLACE '&2' WITH MESSTAB-MSGV2 INTO L_MSTRING.
REPLACE '&3' WITH MESSTAB-MSGV3 INTO L_MSTRING.
REPLACE '&4' WITH MESSTAB-MSGV4 INTO L_MSTRING.
ELSE.
REPLACE '&' WITH MESSTAB-MSGV1 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV2 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV3 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV4 INTO L_MSTRING.
ENDIF.
CONDENSE L_MSTRING.
APPEND L_MSTRING TO LT_SUC_MESSAGE.
ENDIF.
ENDLOOP.
EXPORT LT_SUC_MESSAGE TO MEMORY ID 'SUCCESS'.
LOOP AT MESSTAB WHERE MSGTYP = 'E'.
SELECT SINGLE * FROM T100 WHERE SPRSL = MESSTAB-MSGSPRA
AND ARBGB = MESSTAB-MSGID
AND MSGNR = MESSTAB-MSGNR.
IF SY-SUBRC = 0.
L_MSTRING1 = T100-TEXT.
IF L_MSTRING1 CS '&1'.
REPLACE '&1' WITH MESSTAB-MSGV1 INTO L_MSTRING.
REPLACE '&2' WITH MESSTAB-MSGV2 INTO L_MSTRING.
REPLACE '&3' WITH MESSTAB-MSGV3 INTO L_MSTRING.
REPLACE '&4' WITH MESSTAB-MSGV4 INTO L_MSTRING.
ELSE.
REPLACE '&' WITH MESSTAB-MSGV1 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV2 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV3 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV4 INTO L_MSTRING.
ENDIF.
CONDENSE L_MSTRING1.
APPEND L_MSTRING1 TO LT_FAIL_MESSAGE.
ENDIF.
ENDLOOP.
EXPORT LT_FAIL_MESSAGE TO MEMORY ID 'FAIL'.
ENDFUNCTION.
INCLUDE BDCRECXY .
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(CTU) LIKE APQI-PUTACTIVE DEFAULT 'X'
*" VALUE(MODE) LIKE APQI-PUTACTIVE DEFAULT 'N'
*" VALUE(UPDATE) LIKE APQI-PUTACTIVE DEFAULT 'L'
*" VALUE(GROUP) LIKE APQI-GROUPID OPTIONAL
*" VALUE(USER) LIKE APQI-USERID OPTIONAL
*" VALUE(KEEP) LIKE APQI-QERASE OPTIONAL
*" VALUE(HOLDDATE) LIKE APQI-STARTDATE OPTIONAL
*" VALUE(NODATA) LIKE APQI-PUTACTIVE DEFAULT '/'
*" VALUE(BLDAT_001) LIKE BDCDATA-FVAL DEFAULT '02.09.2014'
*" VALUE(BLART_002) LIKE BDCDATA-FVAL DEFAULT 'sa'
*" VALUE(BUKRS_003) LIKE BDCDATA-FVAL DEFAULT '1000'
*" VALUE(BUDAT_004) LIKE BDCDATA-FVAL DEFAULT '12.09.2014'
*" VALUE(MONAT_005) LIKE BDCDATA-FVAL DEFAULT '10'
*" VALUE(WAERS_006) LIKE BDCDATA-FVAL DEFAULT 'inr'
*" VALUE(XBLNR_007) LIKE BDCDATA-FVAL DEFAULT 'Upload'
*" VALUE(BKTXT_008) LIKE BDCDATA-FVAL DEFAULT 'MINESII Sales'
*" VALUE(DOCID_009) LIKE BDCDATA-FVAL DEFAULT '*'
*" VALUE(NEWBS_010) LIKE BDCDATA-FVAL DEFAULT '40'
*" VALUE(NEWKO_011) LIKE BDCDATA-FVAL DEFAULT '4025100301'
*" VALUE(WRBTR_012) LIKE BDCDATA-FVAL DEFAULT '1000'
*" VALUE(BUPLA_013) LIKE BDCDATA-FVAL DEFAULT 'M00I'
*" VALUE(ZUONR_016) LIKE BDCDATA-FVAL DEFAULT 'upld'
*" VALUE(SGTXT_017) LIKE BDCDATA-FVAL DEFAULT 'olimmslwdger'
*" VALUE(FMORE_018) LIKE BDCDATA-FVAL DEFAULT 'X'
*" VALUE(WRBTR_020) LIKE BDCDATA-FVAL DEFAULT '1000'
*" VALUE(BUPLA_021) LIKE BDCDATA-FVAL DEFAULT 'M00I'
*" VALUE(ZUONR_024) LIKE BDCDATA-FVAL DEFAULT 'upld'
*" VALUE(SGTXT_025) LIKE BDCDATA-FVAL DEFAULT 'olimmslwdger'
*" VALUE(NEWBS_026) LIKE BDCDATA-FVAL DEFAULT '50'
*" VALUE(NEWKO_027) LIKE BDCDATA-FVAL DEFAULT '2220030122'
*" VALUE(FMORE_028) LIKE BDCDATA-FVAL DEFAULT 'X'
*" VALUE(KOSTL_029) LIKE BDCDATA-FVAL DEFAULT 'M010010102'
*" VALUE(PRCTR_030) LIKE BDCDATA-FVAL DEFAULT 'M01002'
*" VALUE(GEBER_031) LIKE BDCDATA-FVAL DEFAULT 'INT-ACCRUL'
*" VALUE(FIPEX_032) LIKE BDCDATA-FVAL DEFAULT 'NONBUDGET'
*" VALUE(FISTL_033) LIKE BDCDATA-FVAL DEFAULT 'M010010102'
*" VALUE(FIPOS_034) LIKE BDCDATA-FVAL DEFAULT 'NONBUDGET'
*" VALUE(WRBTR_035) LIKE BDCDATA-FVAL DEFAULT '1000'
*" VALUE(BUPLA_036) LIKE BDCDATA-FVAL DEFAULT 'M00I'
*" VALUE(ZUONR_039) LIKE BDCDATA-FVAL DEFAULT 'upld'
*" VALUE(SGTXT_040) LIKE BDCDATA-FVAL DEFAULT 'olimmslwdger'
*" VALUE(FMORE_041) LIKE BDCDATA-FVAL DEFAULT 'X'
*" VALUE(PRCTR_042) LIKE BDCDATA-FVAL DEFAULT 'M01001'
*" VALUE(WRBTR_043) LIKE BDCDATA-FVAL DEFAULT '1000'
*" VALUE(BUPLA_044) LIKE BDCDATA-FVAL DEFAULT 'M00I'
*" VALUE(ZUONR_047) LIKE BDCDATA-FVAL DEFAULT 'upld'
*" VALUE(SGTXT_048) LIKE BDCDATA-FVAL DEFAULT 'olimmslwdger'
*" VALUE(NEWBS_049) LIKE BDCDATA-FVAL DEFAULT '40'
*" VALUE(NEWKO_050) LIKE BDCDATA-FVAL DEFAULT '1015060101'
*" VALUE(FMORE_051) LIKE BDCDATA-FVAL DEFAULT 'X'
*" VALUE(PRCTR_052) LIKE BDCDATA-FVAL DEFAULT 'M01001'
*" VALUE(FIPEX_053) LIKE BDCDATA-FVAL DEFAULT 'BALANCESHEET'
*" VALUE(FIPOS_054) LIKE BDCDATA-FVAL DEFAULT 'BALANCESHEET'
*" VALUE(WRBTR_055) LIKE BDCDATA-FVAL DEFAULT '1000'
*" VALUE(BUPLA_056) LIKE BDCDATA-FVAL DEFAULT 'M00I'
*" VALUE(ZUONR_059) LIKE BDCDATA-FVAL DEFAULT 'upld'
*" VALUE(SGTXT_060) LIKE BDCDATA-FVAL DEFAULT 'olimmslwdger'
*" VALUE(FMORE_061) LIKE BDCDATA-FVAL DEFAULT 'X'
*" VALUE(PRCTR_062) LIKE BDCDATA-FVAL DEFAULT 'M01001'
*" VALUE(WRBTR_063) LIKE BDCDATA-FVAL DEFAULT '1000'
*" VALUE(BUPLA_064) LIKE BDCDATA-FVAL DEFAULT 'M00I'
*" VALUE(ZUONR_067) LIKE BDCDATA-FVAL DEFAULT 'upld'
*" VALUE(SGTXT_068) LIKE BDCDATA-FVAL DEFAULT 'olimmslwdger'
*" VALUE(NEWBS_069) LIKE BDCDATA-FVAL DEFAULT '50'
*" VALUE(NEWKO_070) LIKE BDCDATA-FVAL DEFAULT '3005030203'
*" VALUE(FMORE_071) LIKE BDCDATA-FVAL DEFAULT 'X'
*" VALUE(PRCTR_072) LIKE BDCDATA-FVAL DEFAULT 'M01001'
*" VALUE(GEBER_073) LIKE BDCDATA-FVAL DEFAULT 'INT-ACCRUL'
*" VALUE(FIPEX_074) LIKE BDCDATA-FVAL DEFAULT 'BALANCESHEET'
*" VALUE(FIPOS_075) LIKE BDCDATA-FVAL DEFAULT 'BALANCESHEET'
*" VALUE(WRBTR_076) LIKE BDCDATA-FVAL DEFAULT '1000'
*" VALUE(BUPLA_077) LIKE BDCDATA-FVAL DEFAULT 'M00I'
*" VALUE(ZUONR_080) LIKE BDCDATA-FVAL DEFAULT 'upld'
*" VALUE(SGTXT_081) LIKE BDCDATA-FVAL DEFAULT 'olimmslwdger'
*" VALUE(FMORE_082) LIKE BDCDATA-FVAL DEFAULT 'X'
*" VALUE(PRCTR_083) LIKE BDCDATA-FVAL DEFAULT 'M01001'
*" VALUE(WRBTR_084) LIKE BDCDATA-FVAL DEFAULT '1000'
*" VALUE(BUPLA_085) LIKE BDCDATA-FVAL DEFAULT 'M00I'
*" VALUE(ZUONR_088) LIKE BDCDATA-FVAL DEFAULT 'upld'
*" VALUE(SGTXT_089) LIKE BDCDATA-FVAL DEFAULT 'olimmslwdger'
*" VALUE(FMORE_090) LIKE BDCDATA-FVAL DEFAULT 'X'
*" VALUE(PRCTR_091) LIKE BDCDATA-FVAL DEFAULT 'M01001'
*" VALUE(GEBER_092) LIKE BDCDATA-FVAL DEFAULT 'INT-ACCRUL'
*" VALUE(FIPEX_093) LIKE BDCDATA-FVAL DEFAULT 'NONBUDGET'
*" VALUE(FIPOS_094) LIKE BDCDATA-FVAL DEFAULT 'NONBUDGET'
*" EXPORTING
*" VALUE(SUBRC) LIKE SYST-SUBRC
*" TABLES
*" MESSTAB STRUCTURE BDCMSGCOLL OPTIONAL
*" LT_MINESII STRUCTURE ZFI_MINESII
*" LT_ELOG STRUCTURE ZFI_MINESIIELOG
*"----------------------------------------------------------------------
BREAK-POINT.
DATA :LWA_MINESII LIKE LT_MINESII,
LWA_MINESII_TEMP LIKE LT_MINESII.
DATA LT_MINESII_TEMP TYPE TABLE OF ZFI_MINESII.
DATA: LV_COUNTER TYPE CHAR1,
LV_AMT TYPE BDC_FVAL,
LV_INC TYPE I,
LV_DATUM(10) TYPE C,
lv_qty TYPE BDC_FVAL.
* COUNTER TYPE CHAR1.
CONSTANTS:
LC_AMT(15) TYPE C VALUE SPACE,
LC_DCTYP TYPE BDC_FVAL VALUE 'M1',"'ZI',
LC_BUKRS TYPE BDC_FVAL VALUE '1000',
LC_WAERS TYPE BDC_FVAL VALUE 'INR',
LC_ZUONR TYPE BDC_FVAL VALUE 'MINESII SALES',
LC_SGTXT TYPE BDC_FVAL VALUE 'MINESII SALES'.
* LV_COUNTER = 1.
LV_INC = 1.
LT_MINESII_TEMP[] = LT_MINESII[].
LOOP AT LT_MINESII INTO LWA_MINESII.
* clear:lv_qty.
if lwa_minesii-poskey = '01'.
lv_qty = LWA_MINESII-qty.
endif.
IF LWA_MINESII-CR_AMT NE LC_AMT.
LV_AMT = LWA_MINESII-CR_AMT.
ELSEIF LWA_MINESII-DR_AMT NE LC_AMT.
LV_AMT = LWA_MINESII-DR_AMT.
ENDIF.
CONCATENATE SY-DATUM+6(2) '.'
SY-DATUM+4(2) '.'
SY-DATUM+0(4) INTO LV_DATUM.
SUBRC = 0.
**************Processing of Header Record for the first time*******************
ON CHANGE OF LWA_MINESII-COUNTER.
PERFORM BDC_NODATA USING NODATA.
PERFORM OPEN_GROUP USING GROUP USER KEEP HOLDDATE CTU.
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'
LV_DATUM."BLDAT_001.
PERFORM BDC_FIELD USING 'BKPF-BLART'
LC_DCTYP."BLART_002.
PERFORM BDC_FIELD USING 'BKPF-BUKRS'
LC_BUKRS."BUKRS_003.
PERFORM BDC_FIELD USING 'BKPF-BUDAT'
LV_DATUM."BUDAT_004.
PERFORM BDC_FIELD USING 'BKPF-MONAT'
MONAT_005.
PERFORM BDC_FIELD USING 'BKPF-WAERS'
LC_WAERS."WAERS_006.
PERFORM BDC_FIELD USING 'BKPF-XBLNR'
LWA_MINESII-INVOICE_NO."XBLNR_007.
PERFORM BDC_FIELD USING 'BKPF-BKTXT'
BKTXT_008.
PERFORM BDC_FIELD USING 'FS006-DOCID'
DOCID_009.
PERFORM BDC_FIELD USING 'RF05A-NEWBS'
LWA_MINESII-POSKEY."NEWBS_010.
PERFORM BDC_FIELD USING 'RF05A-NEWKO'
LWA_MINESII-GL_MAIN_ACCT."NEWKO_011.
ENDON.
* BREAK-POINT.
******************End of header Record*******************************************
IF LWA_MINESII-POSKEY = '50'.
***********Processing of Next Screens**********************************************
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'
LV_AMT."WRBTR_012.
PERFORM BDC_FIELD USING 'BSEG-BUPLA'
BUPLA_013.
if lwa_minesII-gl_code = '6531'.
PERFORM BDC_FIELD USING 'BSEG-MENGE'
lv_qty.
PERFORM BDC_FIELD USING 'BSEG-MEINS'
'TO'."MEINS_015.
endif.
PERFORM BDC_FIELD USING 'BSEG-ZUONR'
LC_ZUONR."ZUONR_016.
PERFORM BDC_FIELD USING 'BSEG-SGTXT'
LC_SGTXT."SGTXT_017.
PERFORM BDC_FIELD USING 'DKACB-FMORE'
FMORE_018.
***
PERFORM BDC_DYNPRO USING 'SAPLKACB' '0002'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'COBL-KOSTL'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTE'.
* PERFORM BDC_FIELD USING 'COBL-KOSTL'
* LWA_MINESII-KOSTL."KOSTL_019.
PERFORM BDC_FIELD USING 'COBL-PRCTR'
LWA_MINESII-PROF_CEN."KOSTL_019.
* PERFORM BDC_FIELD USING 'COBL-FIPEX'
* 'NONBUDGET'.
***********End Of screens***********************************************************
LV_INC = LV_INC + 1.
*********after all the items are processed posting being done in F-02*********
AT END OF COUNTER.
PERFORM BDC_DYNPRO USING 'SAPMF05A' '0300'. "300 ABHINAV
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BU'.
PERFORM BDC_DYNPRO USING 'SAPLKACB' '0002'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTE'.
PERFORM BDC_DYNPRO USING 'SAPMF05A' '0700'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RF05A-NEWBS'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BU'.
PERFORM BDC_TRANSACTION TABLES MESSTAB
USING 'F-02'
CTU
MODE
UPDATE.
* BREAK-POINT.
IF SY-SUBRC <> 0.
SUBRC = SY-SUBRC.
EXIT.
ENDIF.
PERFORM CLOSE_GROUP USING CTU.
CONTINUE.
ENDAT.
***************End of posting*****************************
************Reading next line item form the Temp. Internal table for Posting key and G/L Acct.
PERFORM BDC_DYNPRO USING 'SAPMF05A' '0300'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
READ TABLE LT_MINESII_TEMP INTO LWA_MINESII_TEMP INDEX LV_INC.
IF SY-SUBRC = 0.
PERFORM BDC_FIELD USING 'RF05A-NEWBS'
LWA_MINESII_TEMP-POSKEY.
PERFORM BDC_FIELD USING 'RF05A-NEWKO'
LWA_MINESII_TEMP-GL_MAIN_ACCT.
** PERFORM BDC_FIELD USING 'RF05A-NEWUM'
** GFS_RECORD-NEWUM.
ENDIF.
PERFORM BDC_DYNPRO USING 'SAPLKACB' '0002'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTE'.
* NEWBS = GFS_RECORD-NEWBS.
CLEAR:LWA_MINESII_TEMP.
CONTINUE.
*************end of reading next line item**************************************
ENDIF.
IF LWA_MINESII-POSKEY = '01'.
PERFORM BDC_DYNPRO USING 'SAPMF05A' '0301'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RF05A-NEWKO'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
* PERFORM BDC_FIELD USING 'BSEG-HKONT'
* GFS_RECORD-HKONT."'2215010101'.
PERFORM BDC_FIELD USING 'BSEG-WRBTR'
LV_AMT."'1000'.
* PERFORM BDC_FIELD USING 'BSEG-MWSKZ'
* '**'.
* PERFORM BDC_FIELD USING 'BSEG-ZTERM'
* GFS_RECORD-ZTERM."'0001'.
PERFORM BDC_FIELD USING 'BSEG-ZFBDT'
LV_DATUM."result."GFS_RECORD-BUDAT."'12.11.2014'.
PERFORM BDC_FIELD USING 'BSEG-ZUONR'
LC_ZUONR."'JJJJJ'.
PERFORM BDC_FIELD USING 'BSEG-SGTXT'
LC_SGTXT."'FFFF'.
LV_INC = LV_INC + 1.
AT END OF COUNTER.
PERFORM BDC_DYNPRO USING 'SAPMF05A' '0301'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BS'.
*BREAK-POINT.
PERFORM BDC_TRANSACTION TABLES MESSTAB
USING 'F-02'
CTU
MODE
UPDATE.
* BREAK-POINT.
IF SY-SUBRC <> 0.
SUBRC = SY-SUBRC.
EXIT.
ENDIF.
PERFORM CLOSE_GROUP USING CTU.
CONTINUE.
ENDAT.
READ TABLE LT_MINESII_TEMP INTO LWA_MINESII_TEMP INDEX LV_INC.
IF SY-SUBRC = 0.
PERFORM BDC_FIELD USING 'RF05A-NEWBS'
LWA_MINESII_TEMP-POSKEY.
PERFORM BDC_FIELD USING 'RF05A-NEWKO'
LWA_MINESII_TEMP-GL_MAIN_ACCT.
** PERFORM BDC_FIELD USING 'RF05A-NEWUM'
** GFS_RECORD-NEWUM.
* PERFORM BDC_FIELD USING 'RF05A-NEWUM'
* GFS_RECORD-NEWUM_012(001).
ENDIF.
CONTINUE.
ENDIF.
ENDLOOP.
**DATA LT_MESSTAB TYPE STANDARD TABLE OF BDCMSGCOLL.
** LT_MESSTAB[] = messtab[].
* BREAK-POINT.
FREE MEMORY ID 'SUCCESS'.
FREE MEMORY ID 'FAIL'.
refresh lt_suc_message[].
refresh lt_fail_message[].
TABLES T100.
LOOP AT MESSTAB WHERE MSGTYP = 'S'.
SELECT SINGLE * FROM T100 WHERE SPRSL = MESSTAB-MSGSPRA
AND ARBGB = MESSTAB-MSGID
AND MSGNR = MESSTAB-MSGNR.
IF SY-SUBRC = 0.
L_MSTRING = T100-TEXT.
IF L_MSTRING CS '&1'.
REPLACE '&1' WITH MESSTAB-MSGV1 INTO L_MSTRING.
REPLACE '&2' WITH MESSTAB-MSGV2 INTO L_MSTRING.
REPLACE '&3' WITH MESSTAB-MSGV3 INTO L_MSTRING.
REPLACE '&4' WITH MESSTAB-MSGV4 INTO L_MSTRING.
ELSE.
REPLACE '&' WITH MESSTAB-MSGV1 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV2 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV3 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV4 INTO L_MSTRING.
ENDIF.
CONDENSE L_MSTRING.
APPEND L_MSTRING TO LT_SUC_MESSAGE.
ENDIF.
ENDLOOP.
EXPORT LT_SUC_MESSAGE TO MEMORY ID 'SUCCESS'.
LOOP AT MESSTAB WHERE MSGTYP = 'E'.
SELECT SINGLE * FROM T100 WHERE SPRSL = MESSTAB-MSGSPRA
AND ARBGB = MESSTAB-MSGID
AND MSGNR = MESSTAB-MSGNR.
IF SY-SUBRC = 0.
L_MSTRING1 = T100-TEXT.
IF L_MSTRING1 CS '&1'.
REPLACE '&1' WITH MESSTAB-MSGV1 INTO L_MSTRING.
REPLACE '&2' WITH MESSTAB-MSGV2 INTO L_MSTRING.
REPLACE '&3' WITH MESSTAB-MSGV3 INTO L_MSTRING.
REPLACE '&4' WITH MESSTAB-MSGV4 INTO L_MSTRING.
ELSE.
REPLACE '&' WITH MESSTAB-MSGV1 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV2 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV3 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV4 INTO L_MSTRING.
ENDIF.
CONDENSE L_MSTRING1.
APPEND L_MSTRING1 TO LT_FAIL_MESSAGE.
ENDIF.
ENDLOOP.
EXPORT LT_FAIL_MESSAGE TO MEMORY ID 'FAIL'.
ENDFUNCTION.
INCLUDE BDCRECXY .
No comments:
Post a Comment