Creating Text in line Item in sap abap
IF gv_salesdocument IS NOT INITIAL.
gs_final-cmr = gv_salesdocument.
SELECT vbeln vgbel
FROM vbak
INTO TABLE gt_vbak
WHERE vbeln = gv_salesdocument.
IF sy-subrc = 0.
SELECT vbeln
posnr
matnr
FROM vbap
INTO TABLE gt_vbap
FOR ALL ENTRIES IN gt_vbak
WHERE vbeln = gt_vbak-vbeln.
ENDIF.
LOOP AT gt_vbap INTO gs_vbap.
CONCATENATE gs_vbap-vbeln gs_vbap-posnr INTO gv_name.
CLEAR gs_vbak.
READ TABLE gt_vbak INTO gs_vbak WITH KEY vbeln = gs_vbap-vbeln.
IF sy-subrc = 0.
CLEAR gs_upload3.
* READ TABLE gt_upload1 INTO gs_upload3 WITH KEY vbeln = gs_vbak-vgbel
* matnr = gs_vbap-matnr
* read = ' '.
READ TABLE gt_upload1 INTO gs_upload3 WITH KEY matnr = gs_vbap-matnr
read = ' '.
IF sy-subrc = 0.
CLEAR lv_tabix.
lv_tabix = sy-tabix.
gs_upload3-read = 'X'.
MODIFY gt_upload1 FROM gs_upload3 INDEX lv_tabix.
gs_tline-tdline = gs_upload3-equnr.
APPEND gs_tline TO gt_tline.
ENDIF.
ENDIF.
CALL FUNCTION 'CREATE_TEXT'
EXPORTING
fid = 'Z002'
flanguage = sy-langu
fname = gv_name
fobject = 'VBBP'
save_direct = 'X'
fformat = '*'
TABLES
flines = gt_tline
EXCEPTIONS
no_init = 1
no_save = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
CLEAR : gs_tline , gt_tline[] .
gs_tline-tdline = gs_upload3-cust_no_date.
APPEND gs_tline TO gt_tline.
CALL FUNCTION 'CREATE_TEXT'
EXPORTING
fid = 'Z001'
flanguage = sy-langu
fname = gv_name
fobject = 'VBBP'
save_direct = 'X'
fformat = '*'
TABLES
flines = gt_tline
EXCEPTIONS
no_init = 1
no_save = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
CLEAR : gs_tline , gt_tline[] .
ENDLOOP.
PERFORM create_credit_memo.
ELSE.
READ TABLE gt_return INTO gs_return WITH KEY type = 'E'.
gs_final-message = gs_return-message.
APPEND gs_final TO gt_final.
CONTINUE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDIF.
gs_final-cmr = gv_salesdocument.
SELECT vbeln vgbel
FROM vbak
INTO TABLE gt_vbak
WHERE vbeln = gv_salesdocument.
IF sy-subrc = 0.
SELECT vbeln
posnr
matnr
FROM vbap
INTO TABLE gt_vbap
FOR ALL ENTRIES IN gt_vbak
WHERE vbeln = gt_vbak-vbeln.
ENDIF.
LOOP AT gt_vbap INTO gs_vbap.
CONCATENATE gs_vbap-vbeln gs_vbap-posnr INTO gv_name.
CLEAR gs_vbak.
READ TABLE gt_vbak INTO gs_vbak WITH KEY vbeln = gs_vbap-vbeln.
IF sy-subrc = 0.
CLEAR gs_upload3.
* READ TABLE gt_upload1 INTO gs_upload3 WITH KEY vbeln = gs_vbak-vgbel
* matnr = gs_vbap-matnr
* read = ' '.
READ TABLE gt_upload1 INTO gs_upload3 WITH KEY matnr = gs_vbap-matnr
read = ' '.
IF sy-subrc = 0.
CLEAR lv_tabix.
lv_tabix = sy-tabix.
gs_upload3-read = 'X'.
MODIFY gt_upload1 FROM gs_upload3 INDEX lv_tabix.
gs_tline-tdline = gs_upload3-equnr.
APPEND gs_tline TO gt_tline.
ENDIF.
ENDIF.
CALL FUNCTION 'CREATE_TEXT'
EXPORTING
fid = 'Z002'
flanguage = sy-langu
fname = gv_name
fobject = 'VBBP'
save_direct = 'X'
fformat = '*'
TABLES
flines = gt_tline
EXCEPTIONS
no_init = 1
no_save = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
CLEAR : gs_tline , gt_tline[] .
gs_tline-tdline = gs_upload3-cust_no_date.
APPEND gs_tline TO gt_tline.
CALL FUNCTION 'CREATE_TEXT'
EXPORTING
fid = 'Z001'
flanguage = sy-langu
fname = gv_name
fobject = 'VBBP'
save_direct = 'X'
fformat = '*'
TABLES
flines = gt_tline
EXCEPTIONS
no_init = 1
no_save = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
CLEAR : gs_tline , gt_tline[] .
ENDLOOP.
PERFORM create_credit_memo.
ELSE.
READ TABLE gt_return INTO gs_return WITH KEY type = 'E'.
gs_final-message = gs_return-message.
APPEND gs_final TO gt_final.
CONTINUE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDIF.
Comments
Post a Comment