Vous êtes sur la page 1sur 6

A.

Enhancement Number: BASD0001


B. Business Purpose: Scenario mapping for GSTR1 DCS portal.
C. Enhancement Type:
D. Project Name / Component name:
E. Enhancement Name:
F. Badi Name: ZFILL_SD_ITEMS
G. Class Name: ZCL_FILL_SD_ITEMS
H. Method Name: FILL_SD_ITEM_GSTR1
I. Include Name:
J. T-code Affected: EDOC_COCKPIT.
K. Remarks:
L. Enhancement Code:

method IF_EDOC_IN_MAP~FILL_SD_ITEM_GSTR1.
*This method will be called for each item of SD invoice
*When IV_SD_PROCESS Equals '0' or '1' or 3 -
B2B, B2C, Export invoice items
* Fill CS_ITEM
*When IV_SD_PROCESS equals '2' or '2A' or '2B' -
Credit note or Debit note or Refund Voucher
* Fill CS_CDN_ITEM
*When IV_SD_PROCESS equal '5' - Taxpaid or downpayment clearing
* Fill CS_TXPD_ITEM
* Below is the sample code for B2B, B2C, Export invoice items Similarly
you need to write the logic
* for remaining scenarios

DATA: ls_excdefn TYPE j_1iexcdefn,


lt_excdefn TYPE TABLE OF j_1iexcdefn,
ls_komv TYPE komv,
lv_taxm TYPE c LENGTH 5,
lv_tax_class TYPE c,
lv_lfdnr TYPE n,
ls_komv1 like ls_komv.

*break abap01.

SELECT * FROM j_1iexcdefn INTO CORRESPONDING FIELDS OF TABLE lt_excdef


n
WHERE kalsm = is_sd_header-kalsm.

CASE is_sd_header-FKART .
WHEN 'ZEXP'.
IF iv_sd_process CA '013'.
CALL FUNCTION 'J_1IG_GET_HSN_SAC'
EXPORTING
im_matnr = is_sd_item-matnr
im_werks = is_sd_item-werks
* im_asnum = ls_sd_item-matnr
im_country = 'IN'
IMPORTING
ex_hsn_sac = cs_item-hsnsac.
* Goods or Service Indicator
IF cs_item-hsnsac IS NOT INITIAL.
CALL METHOD cl_edoc_map_in_utilities=>identify_good_or_servi
ce
EXPORTING
i_hsnsac = cs_item-hsnsac " HSN or SAC Code
IMPORTING
e_type = cs_item-
type. " Returns 'G' for Goods 'S' for Service
ENDIF.
* Item Description
cs_item-description = is_sd_item-arktx.
REPLACE ALL OCCURRENCES OF REGEX '[^[:alpha:]1234567890 ]' IN
cs_item-description WITH space.
* Item quantity & Unit Quantity Code
IF cs_item-type = 'G'. "Goods
cs_item-quantity = is_sd_item-fkimg.
CALL METHOD cl_edoc_map_in_utilities=>get_unit_quant_code
EXPORTING
iv_msehi = is_sd_item-meins
IMPORTING
ev_uqc = cs_item-uqc.
ENDIF.

READ TABLE is_sd_invoice-


conditions_record INTO ls_komv1 WITH key knumv = is_sd_header-
knumv kposn = is_sd_item-posnr
kstat = 'X' kinak =
space koaid = 'D'.
if sy-subrc = 0.
LOOP AT is_sd_invoice-conditions_record INTO ls_komv
WHERE knumv EQ is_sd_header-knumv
AND kposn EQ is_sd_item-posnr
* AND kstat NE 'X'
AND kstat eq 'X'
AND kinak EQ space
AND koaid EQ 'D'.

READ TABLE lt_excdefn INTO ls_excdefn


WITH KEY kalsm = is_sd_header-kalsm
kschl = ls_komv-kschl.
CASE ls_excdefn-cond_name.
WHEN 'CGSTAR'.
cs_item-taxbase = abs( ls_komv-kawrt ).
cs_item-cgstamt = abs( ls_komv-kwert ).
cs_item-cgstrate = abs( ls_komv-kbetr / 10 ).
WHEN 'SGSTAR'.
cs_item-taxbase = abs( ls_komv-kawrt ).
cs_item-sgstamt = abs( ls_komv-kwert ).
cs_item-sgstrate = abs( ls_komv-kbetr / 10 ).
WHEN 'IGSTAR'.
SELECT SINGLE MWSBP FROM vbrp INTO ls_komv-
kwert WHERE vbeln eq IS_SD_HEADER-vbeln and posnr eq is_sd_item-posnr.
if sy-subrc = 0.
cs_item-igstamt = abs( ls_komv-kwert ).
endif.
cs_item-taxbase = abs( ls_komv-kawrt ).
cs_item-igstrate = '0.00'. "abs( ls_komv-
kbetr / 10 ). Code Added Reshma as per SAP sugestion on WOPAY export
WHEN 'UTGSTAR'.
cs_item-taxbase = abs( ls_komv-kawrt ).
cs_item-sgstamt = abs( ls_komv-kwert ).
cs_item-sgstrate = abs( ls_komv-kbetr / 10 ).
WHEN 'CCPSOFFAR'.
cs_item-taxbase = abs( ls_komv-kawrt ).
cs_item-cessamt = cs_item-cessamt + ls_komv-kwert.
cs_item-cessamt = abs( cs_item-cessamt ).
cs_item-cessrate = abs( ls_komv-kbetr / 10 ).
WHEN 'CCQSOFFAR'.
cs_item-taxbase = abs( ls_komv-kawrt ).
cs_item-cessamt = cs_item-cessamt + ls_komv-kwert.
cs_item-cessamt = abs( cs_item-cessamt ).
ENDCASE.
CLEAR: ls_komv, ls_excdefn.

ENDLOOP.
else.
LOOP AT is_sd_invoice-conditions_record INTO ls_komv
WHERE knumv EQ is_sd_header-knumv
AND kposn EQ is_sd_item-posnr
AND kstat eq space
AND kinak EQ space
AND koaid EQ 'D'.

READ TABLE lt_excdefn INTO ls_excdefn


WITH KEY kalsm = is_sd_header-kalsm
kschl = ls_komv-kschl.
CASE ls_excdefn-cond_name.
WHEN 'CGSTAR'.
cs_item-taxbase = abs( ls_komv-kawrt ).
cs_item-cgstamt = abs( ls_komv-kwert ).
cs_item-cgstrate = abs( ls_komv-kbetr / 10 ).
WHEN 'SGSTAR'.
cs_item-taxbase = abs( ls_komv-kawrt ).
cs_item-sgstamt = abs( ls_komv-kwert ).
cs_item-sgstrate = abs( ls_komv-kbetr / 10 ).
WHEN 'IGSTAR'.
cs_item-igstamt = abs( ls_komv-kwert ).
cs_item-taxbase = abs( ls_komv-kawrt ).
cs_item-igstrate = abs( ls_komv-kbetr / 10 ).
WHEN 'UTGSTAR'.
cs_item-taxbase = abs( ls_komv-kawrt ).
cs_item-sgstamt = abs( ls_komv-kwert ).
cs_item-sgstrate = abs( ls_komv-kbetr / 10 ).
WHEN 'CCPSOFFAR'.
cs_item-taxbase = abs( ls_komv-kawrt ).
cs_item-cessamt = cs_item-cessamt + ls_komv-kwert.
cs_item-cessamt = abs( cs_item-cessamt ).
cs_item-cessrate = abs( ls_komv-kbetr / 10 ).
WHEN 'CCQSOFFAR'.
cs_item-taxbase = abs( ls_komv-kawrt ).
cs_item-cessamt = cs_item-cessamt + ls_komv-kwert.
cs_item-cessamt = abs( cs_item-cessamt ).
ENDCASE.
CLEAR: ls_komv, ls_excdefn.
endloop.
endif.

ENDIF.
** * NR - Nil Rated, EX - Exempted, NG - Non GST
* SELECT SINGLE lfdnr INTO lv_lfdnr FROM tstl WHERE talnd = 'IN'
* AND tatyp = 'JOIG'.
* IF sy-subrc EQ 0.
* CONCATENATE 'TAXM' lv_lfdnr INTO lv_taxm.
* SELECT SINGLE (lv_taxm) FROM mlan INTO lv_tax_class
* WHERE matnr = is_sd_item-matnr
* AND aland = 'IN'.
* IF sy-subrc EQ 0.
* CASE lv_tax_class.
* WHEN '1'.
* cs_item-niltype = 'EX'.
* WHEN '2'.
* cs_item-niltype = 'NG'.
* WHEN '0'.
* IF cs_item-igstrate IS INITIAL
* AND cs_item-cgstrate IS INITIAL
* AND cs_item-sgstrate IS INITIAL.
* cs_item-niltype = 'NR'.
* ENDIF.
* ENDCASE.
*
* ENDIF.
* ENDIF.

WHEN 'ZERE' or 'ZECR' or 'ZEDR'.

IF iv_sd_process = '2' or iv_sd_process = '2A'.


* CALL FUNCTION 'J_1IG_GET_HSN_SAC'
* EXPORTING
* im_matnr = is_sd_item-matnr
* im_werks = is_sd_item-werks
** im_asnum = ls_sd_item-matnr
* im_country = 'IN'
* IMPORTING
* ex_hsn_sac = cs_item-hsnsac.
** Goods or Service Indicator
* IF cs_item-hsnsac IS NOT INITIAL.
* CALL METHOD cl_edoc_map_in_utilities=>identify_good_or_serv
ice
* EXPORTING
* i_hsnsac = cs_item-hsnsac " HSN or SAC Code
* IMPORTING
* e_type = CS_CDN_ITEM-
type. " Returns 'G' for Goods 'S' for Service
* ENDIF.
* Item Description
* CS_CDN_ITEM-description = is_sd_item-arktx.
* REPLACE ALL OCCURRENCES OF REGEX '[^[:alpha:]1234567890 ]' IN
cs_item-description WITH space.
* Item quantity & Unit Quantity Code
* IF CS_CDN_ITEM-type = 'G'. "Goods
* CS_CDN_ITEM-quantity = is_sd_item-fkimg.
* CALL METHOD cl_edoc_map_in_utilities=>get_unit_quant_code
* EXPORTING
* iv_msehi = is_sd_item-meins
* IMPORTING
* ev_uqc = CS_CDN_ITEM-uqc.
* ENDIF.

READ TABLE is_sd_invoice-


conditions_record INTO ls_komv1 WITH key knumv = is_sd_header-
knumv kposn = is_sd_item-posnr
kstat = 'X' kinak =
space koaid = 'D'.
if sy-subrc = 0.
LOOP AT is_sd_invoice-conditions_record INTO ls_komv
WHERE knumv EQ is_sd_header-knumv
AND kposn EQ is_sd_item-posnr
* AND kstat NE 'X'
AND kstat eq 'X'
AND kinak EQ space
AND koaid EQ 'D'.

READ TABLE lt_excdefn INTO ls_excdefn


WITH KEY kalsm = is_sd_header-kalsm
kschl = ls_komv-kschl.
CASE ls_excdefn-cond_name.
WHEN 'CGSTAR'.
cs_item-taxbase = abs( ls_komv-kawrt ).
CS_CDN_ITEM-cgstamt = abs( ls_komv-kwert ).
CS_CDN_ITEM-cgstrate = abs( ls_komv-kbetr / 10 ).
WHEN 'SGSTAR'.
CS_CDN_ITEM-taxbase = abs( ls_komv-kawrt ).
CS_CDN_ITEM-sgstamt = abs( ls_komv-kwert ).
CS_CDN_ITEM-sgstrate = abs( ls_komv-kbetr / 10 ).
WHEN 'IGSTAR'.
SELECT SINGLE MWSBP FROM vbrp INTO ls_komv-
kwert WHERE vbeln eq IS_SD_HEADER-vbeln and posnr eq is_sd_item-posnr.
if sy-subrc = 0.
CS_CDN_ITEM-igstamt = abs( ls_komv-kwert ).
endif.
CS_CDN_ITEM-taxbase = abs( ls_komv-kawrt ).
CS_CDN_ITEM-igstrate = '0.00'. "abs( ls_komv-
kbetr / 10 ). ***code by Reshma BOND case Keeping rate as zero as sugg
ested by SAP 09.11.2017
WHEN 'UTGSTAR'.
CS_CDN_ITEM-taxbase = abs( ls_komv-kawrt ).
CS_CDN_ITEM-sgstamt = abs( ls_komv-kwert ).
CS_CDN_ITEM-sgstrate = abs( ls_komv-kbetr / 10 ).
WHEN 'CCPSOFFAR'.
CS_CDN_ITEM-taxbase = abs( ls_komv-kawrt ).
CS_CDN_ITEM-cessamt = CS_CDN_ITEM-cessamt + ls_komv-kwert.
CS_CDN_ITEM-cessamt = abs( CS_CDN_ITEM-cessamt ).
CS_CDN_ITEM-cessrate = abs( ls_komv-kbetr / 10 ).
WHEN 'CCQSOFFAR'.
CS_CDN_ITEM-taxbase = abs( ls_komv-kawrt ).
CS_CDN_ITEM-cessamt = CS_CDN_ITEM-cessamt + ls_komv-kwert.
CS_CDN_ITEM-cessamt = abs( CS_CDN_ITEM-cessamt ).
ENDCASE.
CLEAR: ls_komv, ls_excdefn.

ENDLOOP.

method IF_EDOC_IN_MAP~DETERMINE_MM_PROCESS_GSTR2.
if c_process is INITIAL.
c_process = '1'.
endif.
endmethod