Technical Articles
Sales invoice with HSNWISE Summary /Annexure/ discount bifurcation in sap.
Introduction
After GST implementation in India, Our distributor ask discount bifurcation, serial number blank for free line item and HSNWISE Summary to easily understanding invoice format, to achieve this working around the same and write the blog.
Functionality Description:
- Create driver program (DP).
- Create smart form
- Assign DP and Smart form to output type.
Processing Requirements and Technical Explanation.
- Using the NACE setting we get the Billing document(VBELN) pass that vbeln to smart form using the below FM.
* call smartform invoice CALL FUNCTION lf_fm_name EXPORTING archive_index = toa_dara * ARCHIVE_INDEX_TAB = archive_parameters = arc_params control_parameters = ls_control_param * MAIL_APPL_OBJ = mail_recipient = ls_recipient mail_sender = ls_sender output_options = ls_composer_param user_settings = space i_vbeln = ls_bil_invoice-hd_gen-bil_number i_ctext = l_text l_flagemail = l_flagemail IMPORTING job_output_info = ls_job_info EXCEPTIONS formatting_error = 1 internal_error = 2 send_error = 3 user_canceled = 4 OTHERS = 5. IF sy-subrc = 0. ls_control_param-no_open = 'X'. ls_control_param-no_close = 'X'. ENDIF.
- IN smartform,Global Definition –> Initialization, pass the vbeln to VBRK and VBRP table and store into internal table gt_vbrk and gt_vbrp.
- loop the gt_vbrp internal table and update the HSNCODE to TXJCD field in the gt_vbrp .
**********append HSN CODE to invoice line items LOOP AT gt_vbrp INTO gw_vbrp. DATA: l_steuc TYPE marc-steuc, l_text1 TYPE t604n-text1. CLEAR: gv_tab_hsnsac. CLEAR: l_steuc, l_text1. SELECT SINGLE steuc FROM marc INTO l_steuc WHERE matnr EQ gw_vbrp-matnr AND werks EQ gw_vbrp-werks. IF sy-subrc = 0. gv_tab_hsnsac = ''. CONCATENATE gv_tab_hsnsac l_steuc INTO gv_tab_hsnsac. ENDIF. CONDENSE gv_tab_hsnsac. gw_vbrp-TXJCD = gv_tab_hsnsac. MODIFY gt_vbrp FROM gw_vbrp INDEX sy-tabix. ENDLOOP. **********End of append HSN CODE to invoice line items ***For HSNWISE Summary gt_vbrp_hsn[] = gt_vbrp[]. sort gt_vbrp_hsn by TXJCD. DELETE ADJACENT DUPLICATES FROM gt_vbrp_hsn COMPARING TXJCD.
- create Three tables in Main areaFirst table for billing line item : Loop table gt_vbrp.Append discount condition description and value to discount internal table.
CLEAR : gw_spd_rdd. DATA : lv_name TYPE thead-tdname. DATA : char_name(20) TYPE c, lines TYPE tline OCCURS 0 WITH HEADER LINE, lv_con_text TYPE string, lv_crecno TYPE string. CLEAR : lv_name,char_name,lines[],lv_con_text,lv_crecno. break nandeesha. CONCATENATE lw_konv-knumh '01' INTO lv_crecno. char_name = lv_crecno. lv_name = char_name. *&---- Transporter CALL FUNCTION 'READ_TEXT' EXPORTING client = sy-mandt id = '0001' language = sy-langu name = lv_name object = 'KONP' TABLES lines = lines EXCEPTIONS id = 1 language = 2 name = 3 not_found = 4 object = 5 reference_check = 6 wrong_access_to_archive = 7 OTHERS = 8. IF sy-subrc <> 0. * Implement suitable error handling here ENDIF. DELETE lines WHERE tdline IS INITIAL. IF lines[] IS NOT INITIAL. CLEAR lv_con_text. LOOP AT lines. CONCATENATE lv_con_text lines-tdline INTO lv_con_text. ENDLOOP. ENDIF. CONDENSE lv_con_text. REFRESH: lines[]. IF lv_con_text IS NOT INITIAL. gw_spd_rdd-pro_txt = lv_con_text. ELSE. SELECT SINGLE vtext FROM t685t INTO gw_spd_rdd-pro_txt WHERE kschl = lw_cond_tab-kschl AND spras = 'EN' AND kvewe = 'A'. ENDIF. gw_spd_rdd-kschl = lw_cond_tab-kschl. gw_spd_rdd-amnt = lw_konv-kwert. gw_spd_rdd-remarks = 'RDD'. APPEND gw_spd_rdd TO gt_spd_rdd.
Second table for HSNWISE Summary : Loop gt_vbrp_hsn.
Third table for Discount provided details : loop gt_spd_rdd.
Out Put.
- Conclusion
SAP Smart forms is the wonder full design tool for design the industrial/Management/Stakeholder expected invoice print out designed with dynamically ,effectively, please comment if any queries to meet this requirement.
If HSN Code in Master (MARC-STEUC) is changed after Billing, how can we achieve the below :
This would be possible only if we have a field in VBRP or any other Billing Item level table where the STEUC is captured as of the transaction (and not go to MARC-STEUC for every lookup).
Regards
V Mani