Sample Program to Create Sales Order – Create Billing Doc – Attach a PDF Document and Release to Accounting

This sample program will create sales order from a data feed from a file, create billing document for those orders, attach a PDF document for these billing document and release those documents to accounting.

This program can also be referred to get sample code for following SAP Function modules:

  • SD_SALES_DOCUMENT_INIT
  • SD_SALES_DOCUMENT_COPY
  • SD_SALES_DOCUMENT_SAVE
  • SD_SALESDOCUMENT_CHANGE

Though this program uses a Z function module to attach a PDF document to the billing document (invoice) I will share the source code for the same in my next post.



*&---------------------------------------------------------------------*
*& Report name : Conversion Program - Cost Centre Copy
*& Purpose : This program will create invoices from data
*& provided through a flat file. This program
*& is needed for ePT project - migration of open
*& invoices from PeopleSoft.
*& This program will do following steps to
*& create invoices to reflect in FTS:
*& 1. Create a Sales Order (Draft Invoice)
*& 2. Create Billing Document (Invoice)
*& 3. Release to Accounting
*& 4. Attach PDF document to the Billing Doc
*&---------------------------------------------------------------------*
************************************************************************

REPORT zsdcc001_ept_invoice_upload
MESSAGE-ID zemsd
LINE-SIZE 165
LINE-COUNT 65.

TYPE-POOLS: slis.

*---------------------------------------------------------------*
* D A T A D E C L A R A T I O N *
*---------------------------------------------------------------*
DATA: BEGIN OF gt_file OCCURS 0,
client LIKE kuagv-kunnr, " Client / Sold to Party
fee_amnt
LIKE komv-kbetr, " Fixed Fee Amount
exp_amnt
LIKE komv-kbetr, " Expense Amount
wbs
LIKE cobl-ps_posid, " WBS Element
inv_dat(
10) TYPE c, " Billing/Invoice Date
END OF gt_file.

DATA: BEGIN OF gt_contract OCCURS 0,
posid
LIKE prps-posid,
zzvbeln
LIKE prps-zzvbeln,
END OF gt_contract.

DATA: BEGIN OF gt_main OCCURS 0,
wbs
LIKE prps-posid, " WBS Element
contr
LIKE prps-zzvbeln, " Contract
fee_amnt
LIKE komv-kbetr, " Fixed Fee Amount
exp_amnt
LIKE komv-kbetr, " Expense Amount
order LIKE vbak-vbeln, " SalesOrder / Draft Inv No.
inv
LIKE vbrk-vbeln, " Invoice/Billing Doc No.
inv_dat(
10) TYPE c, " Invoice Date
acc_rel
TYPE c, " Flag for Released to Accounting
att_pdf
TYPE c, " Flag for Document Attached
message LIKE bapiret2-message, " Message
END OF gt_main.

DATA: g_vbeln LIKE bapivbeln-vbeln,
g_vbeln_bill
LIKE bapivbeln-vbeln. ""

DATA: gt_return TYPE STANDARD TABLE OF bapiret2 WITH HEADER LINE.
DATA: gt_bdcdata TYPE STANDARD TABLE OF bdcdata WITH HEADER LINE.

DATA: gt_fieldcat TYPE slis_t_fieldcat_alv.

*---------------------------------------------------------------*
* S E L E C T I O N S C R E E N *
*---------------------------------------------------------------*
SELECTION-
SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_fname LIKE ibipparms-path OBLIGATORY.
SELECTION-
SCREEN END OF BLOCK b1.

*---------------------------------------------------------------*
* A T S E L E C T I O N S C R E E N *
*---------------------------------------------------------------*

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname.

CALL FUNCTION 'F4_FILENAME'
* EXPORTING
* PROGRAM_NAME = SYST-CPROG
* DYNPRO_NUMBER = SYST-DYNNR
* FIELD_NAME = ' '
IMPORTING
file_name = p_fname
.

*---------------------------------------------------------------*
* S T A R T O F S E L E C T I O N *
*---------------------------------------------------------------*
START-
OF-SELECTION.

* Read data from flat file
PERFORM a001_read_from_file.

* Process data for upload
PERFORM a002_process_data.

* Upload Data to R/3
PERFORM a003_upload_data.

* Display Report Output
PERFORM a004_display_output.

*---------------------------------------------------------------*
* S U B R O U T I N E S *
*---------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form A001_READ_FROM_FILE
*&---------------------------------------------------------------------*
* Read Data from Flat File
*----------------------------------------------------------------------*

FORM a001_read_from_file .

DATA: l_filename TYPE string.

l_filename = p_fname.

CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_filename
* FILETYPE = 'ASC'
has_field_separator =
'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* VIRUS_SCAN_PROFILE =
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = gt_file
EXCEPTIONS
file_open_error =
1
file_read_error =
2
no_batch =
3
gui_refuse_filetransfer =
4
invalid_type =
5
no_authority =
6
unknown_error =
7
bad_data_format =
8
header_not_allowed =
9
separator_not_allowed =
10
header_too_long =
11
unknown_dp_error =
12
access_denied =
13
dp_out_of_memory =
14
disk_full =
15
dp_timeout =
16
OTHERS = 17
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

* Delete Blank Lines
DELETE gt_file WHERE wbs IS INITIAL.

IF gt_file[] IS INITIAL.
MESSAGE s000(zemsd) WITH text-002 DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDIF.

ENDFORM. " A001_READ_FROM_FILE

*&---------------------------------------------------------------------*
*& Form a002_process_data
*&---------------------------------------------------------------------*
* Process Data for Upload and Get Additional Data
*----------------------------------------------------------------------*
FORM a002_process_data .


IF NOT gt_file[] IS INITIAL.

SELECT posid zzvbeln
INTO TABLE gt_contract
FROM prps
FOR ALL ENTRIES IN gt_file
WHERE posid EQ gt_file-wbs.
IF sy-subrc EQ 0.
SORT gt_contract BY posid.
ENDIF.

ENDIF.

LOOP AT gt_file.

CLEAR gt_main.

gt_main-wbs = gt_file-wbs.
gt_main-fee_amnt = gt_file-fee_amnt.
gt_main-exp_amnt = gt_file-exp_amnt.
gt_main-inv_dat = gt_file-inv_dat .

READ TABLE gt_contract WITH KEY posid = gt_main-wbs
BINARY SEARCH.
IF sy-subrc EQ 0.
gt_main-contr = gt_contract-zzvbeln.
ELSE.
gt_main-
message = text-m01 .
ENDIF.

APPEND gt_main.

ENDLOOP.

ENDFORM. " a002_process_data

*&---------------------------------------------------------------------*
*& Form a003_upload_data
*&---------------------------------------------------------------------*
* Upload Data to R/3
*----------------------------------------------------------------------*

FORM a003_upload_data .

DATA: l_index(3) TYPE n.

LOOP AT gt_main.

l_index = sy-tabix.

CONCATENATE '*-----Begin of Log:Record'
l_index
'WBS:'
gt_main-wbs
'-----*'
INTO gt_return-message
SEPARATED BY space.
APPEND gt_return.

IF NOT gt_main-contr IS INITIAL.



* Create Sales Order/Draft Invoice
PERFORM b001_create_sales_order USING gt_main-contr
gt_main-fee_amnt
gt_main-exp_amnt
CHANGING gt_main-order
gt_main-
message.

IF NOT gt_main-order IS INITIAL AND
gt_main-
message IS INITIAL.

* Create Invoice
PERFORM b002_create_invoice USING gt_main-order
gt_main-inv_dat
CHANGING gt_main-inv
gt_main-
message.

IF NOT gt_main-inv IS INITIAL.
* Release for Accounting
PERFORM b003_release_for_acc USING gt_main-inv
CHANGING gt_main-message.

IF gt_main-message IS INITIAL.
gt_main-acc_rel =
'X'.
ENDIF.
* Attach PDF Document(Invoice)
PERFORM b004_attach_pdf USING gt_main-inv
CHANGING gt_main-message.

IF gt_main-message IS INITIAL.
gt_main-att_pdf =
'X'.
ENDIF.
ENDIF.
ENDIF.
ENDIF.

MODIFY gt_main.

CONCATENATE '*-----End of Log:Record'
l_index
'WBS:'
gt_main-wbs
'-----*'
INTO gt_return-message
SEPARATED BY space.
APPEND gt_return.

ENDLOOP.

ENDFORM. " a003_upload_data

*&---------------------------------------------------------------------*
*& Form b001_create_sales_order
*&---------------------------------------------------------------------*
* Create Sales Order / Draft Invoice
*----------------------------------------------------------------------*

FORM b001_create_sales_order USING p_contract
p_condvalue_fee
p_condvalue_exp
CHANGING vbeln
message.

DATA: l_ord_typ LIKE vbak-auart VALUE 'ZFBR',
l_contract
LIKE vbak-vbeln,
l_n10(
10) TYPE n,
l_vbakkom
LIKE vbakkom,
l_vbak
LIKE vbak,
l_netwr
LIKE vbap-netwr,

l_headerx
LIKE bapisdhd1x.

DATA: lt_cond TYPE STANDARD TABLE OF bapicond WITH HEADER LINE,
lt_condx
TYPE STANDARD TABLE OF bapicondx WITH HEADER LINE,
lt_return
TYPE STANDARD TABLE OF bapiret2 WITH HEADER LINE.

* Header
l_n10 = p_contract.
"Padding with Zeros
l_contract = l_n10.
"Contract.


CALL FUNCTION 'SD_SALES_DOCUMENT_INIT'
EXPORTING
status_buffer_refresh =
'X'
EXCEPTIONS
error_message =
01.

IF sy-subrc EQ 1.
gt_return-
message = text-m02.
APPEND gt_return.

message = text-m02.
ENDIF.

CALL FUNCTION 'SD_SALES_DOCUMENT_COPY'
EXPORTING
i_auarn = l_ord_typ
i_vbeln = l_contract
* I_ITEMS_COPY = 'X'
* I_KEEP_LOCK_ENTRY = ' '
* IS_ENHANCEMENT =
IMPORTING
fvbakkom = l_vbakkom
* ES_ENHANCEMENT =
* TABLES
* IX_VBAPKOMX_ORIG =
* CHANGING
* CS_ENHANCEMENT =
EXCEPTIONS
ism_incomplete =
1
ism_generation_error =
2
OTHERS = 3
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL FUNCTION 'SD_SALES_DOCUMENT_SAVE'
EXPORTING
synchron =
'X'
IMPORTING
evbak = l_vbak
EXCEPTIONS
error_message =
01.

vbeln = l_vbak-vbeln.

COMMIT WORK.
WAIT UP TO 5 SECONDS.

* Update Sales Order / Draft Invoice

l_headerx-updateflag =
'U'.

* Pricing Conditions
IF NOT p_condvalue_fee IS INITIAL.
lt_cond-itm_number =
'10'.
lt_cond-cond_type =
'ZFFR'.
lt_cond-cond_value = p_condvalue_fee.
" Fee Amount
lt_cond-
currency = 'USD'.
APPEND lt_cond.
ENDIF.

IF NOT p_condvalue_exp IS INITIAL.
lt_cond-itm_number =
'20'.
lt_cond-cond_type =
'ZFEA'.
lt_cond-cond_value = p_condvalue_exp.
"Expense Amount
lt_cond-
currency = 'USD'.
APPEND lt_cond.
ENDIF.

CALL FUNCTION 'SD_SALESDOCUMENT_CHANGE'
EXPORTING
salesdocument = vbeln
* ORDER_HEADER_IN =
order_header_inx = l_headerx
* SIMULATION = ' '
* INT_NUMBER_ASSIGNMENT = ' '
* BEHAVE_WHEN_ERROR = ' '
* BUSINESS_OBJECT = ' '
* CONVERT_PARVW_AUART = ' '
* CALL_FROM_BAPI = ' '
* LOGIC_SWITCH =
* I_CRM_LOCK_MODE = ' '
* NO_STATUS_BUF_INIT = ' '
* IMPORTING
* SALES_HEADER_OUT =
* SALES_HEADER_STATUS =
TABLES
return = lt_return
* ITEM_IN =
* ITEM_INX =
* SCHEDULE_IN =
* SCHEDULE_INX =
* PARTNERS =
* PARTNERCHANGES =
* PARTNERADDRESSES =
* SALES_CFGS_REF =
* SALES_CFGS_INST =
* SALES_CFGS_PART_OF =
* SALES_CFGS_VALUE =
* SALES_CFGS_BLOB =
* SALES_CFGS_VK =
* SALES_CFGS_REFINST =
* SALES_CCARD =
* SALES_TEXT =
* SALES_KEYS =
conditions_in = lt_cond
* CONDITIONS_INX = lt_condx
* SALES_CONTRACT_IN =
* SALES_CONTRACT_INX =
* EXTENSIONIN =
* ITEMS_EX =
* SCHEDULE_EX =
* BUSINESS_EX =
* INCOMPLETE_LOG =
* EXTENSIONEX =
* CONDITIONS_EX =
* SALES_SCHED_CONF_IN =
* DEL_SCHEDULE_EX =
* DEL_SCHEDULE_IN =
* DEL_SCHEDULE_INX =
* CORR_CUMQTY_IN =
* CORR_CUMQTY_INX =
* CORR_CUMQTY_EX =
* PARTNERS_EX =
* TEXTHEADERS_EX =
* TEXTLINES_EX =
* BATCH_CHARC =
* CAMPAIGN_ASGN =
.

APPEND LINES OF lt_return TO gt_return.

READ TABLE lt_return WITH KEY type = 'E'.
IF sy-subrc EQ 0.
SELECT SINGLE netwr INTO l_netwr
FROM vbap
WHERE vbeln EQ vbeln
AND posnr EQ '10'.
IF sy-subrc NE 0 OR
l_netwr
EQ 0.
message = text-m06.
ENDIF.
ENDIF.

COMMIT WORK.
WAIT UP TO 5 SECONDS.

ENDFORM. " b001_create_sales_order
*&---------------------------------------------------------------------*
*& Form b002_create_invoice
*&---------------------------------------------------------------------*
* Create Invoice / Billing Document
*----------------------------------------------------------------------*

FORM b002_create_invoice USING p_order
p_inv_dat
CHANGING vbeln
message .

DATA: lt_msg TYPE STANDARD TABLE OF bdcmsgcoll WITH HEADER LINE,
l_mode
TYPE c,
l_vbeln
LIKE vbak-vbeln.


CLEAR: gt_bdcdata,
gt_bdcdata[].

* Check whether Order exists in the system yet. Check 3 times.
DO 3 TIMES.
SELECT SINGLE vbeln INTO l_vbeln
FROM vbak
WHERE vbeln EQ p_order.
IF sy-subrc EQ 0.
EXIT.
ENDIF.
ENDDO.

* Populating the BDC table with various screen fields
* Use BDC to create new pricing document
PERFORM sub_bdc_dynpro USING 'SAPMV60A' '0102'.

PERFORM sub_bdc_field USING:
'BDC_OKCODE' '=SICH', "'=FAKT',
'RV60A-FKDAT' p_inv_dat,
'RV60A-SELKZ(01)' 'X',
'KOMFK-VBELN(01)' p_order.

l_mode =
'N'.

CALL TRANSACTION 'VF01' USING gt_bdcdata
MODE l_mode
MESSAGES
INTO lt_msg.

LOOP AT lt_msg.

CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = lt_msg-msgid
msgnr = lt_msg-msgnr
msgv1 = lt_msg-msgv1
msgv2 = lt_msg-msgv2
msgv3 = lt_msg-msgv3
msgv4 = lt_msg-msgv4
IMPORTING
message_text_output = gt_return-
message.

gt_return-
type = lt_msg-msgtyp.
gt_return-
id = lt_msg-msgid.
gt_return-
number = lt_msg-msgnr.

APPEND gt_return.

IF lt_msg-msgtyp EQ 'S' AND
lt_msg-msgnr
EQ '050' AND
lt_msg-msgid
EQ 'VF' AND
vbeln
IS INITIAL.
vbeln = lt_msg-msgv1.
ENDIF.
ENDLOOP.

WAIT UP TO 5 SECONDS.

IF vbeln IS INITIAL.
message = text-m03.
ENDIF.

ENDFORM. " b002_create_invoice
*&---------------------------------------------------------------------*
*& Form b003_release_for_acc
*&---------------------------------------------------------------------*
* Release the Billing Document to Accounting
*----------------------------------------------------------------------*

FORM b003_release_for_acc USING p_vbeln
CHANGING message.

DATA: lt_msg TYPE STANDARD TABLE OF bdcmsgcoll WITH HEADER LINE,
l_mode
TYPE c.

CLEAR: gt_bdcdata,
gt_bdcdata[].

PERFORM sub_bdc_dynpro USING : 'SAPMV60A' '0101'.

PERFORM sub_bdc_field USING: 'BDC_OKCODE' '=FKFR',
'VBRK-VBELN' p_vbeln.

l_mode =
'N'.

CALL TRANSACTION 'VF02' USING gt_bdcdata
MODE l_mode
MESSAGES
INTO lt_msg.
IF sy-subrc NE 0.
message = text-m04.
ENDIF.

LOOP AT lt_msg.

CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = lt_msg-msgid
msgnr = lt_msg-msgnr
msgv1 = lt_msg-msgv1
msgv2 = lt_msg-msgv2
msgv3 = lt_msg-msgv3
msgv4 = lt_msg-msgv4
IMPORTING
message_text_output = gt_return-
message.

gt_return-
type = lt_msg-msgtyp.
gt_return-
id = lt_msg-msgid.
gt_return-
number = lt_msg-msgnr.

APPEND gt_return.

ENDLOOP.

WAIT UP TO 5 SECONDS.

ENDFORM. " b003_release_for_acc

*&---------------------------------------------------------------------*
*& Form b004_attach_pdf
*&---------------------------------------------------------------------*
* Create Invoice Document(PDF) and Attach it to Billing Document
*----------------------------------------------------------------------*

FORM b004_attach_pdf USING p_vbeln
CHANGING message .

DATA: l_formname LIKE stxfadm-formname,
l_n10(
10) TYPE n,
l_vbeln
LIKE vbrk-vbeln.

*Padding with Zeros
l_n10 = p_vbeln.
l_vbeln = l_n10.

SELECT SINGLE b~sform INTO l_formname
FROM nast AS a
INNER
JOIN tnapr AS b ON b~kschl = a~kschl AND
b~nacha =
'1' AND
b~kappl =
'V3'
WHERE a~kappl = 'V3'
AND a~objky = l_vbeln
AND a~nacha = '1'.

IF sy-subrc EQ 0.

CALL FUNCTION 'Z_WF_DISPLAY_PDF_INVOICE'
EXPORTING
vbeln = l_vbeln
form_name = l_formname
display_pdf =
'A'
* IMPORTING
* FILE_SIZE =
* NEW_SOFM_KEY =
* TABLES
* PDF_TEXT =
EXCEPTIONS
smart_form_error =
1
OTHERS = 2
.
IF sy-subrc <> 0.
message = text-m05.
ENDIF.

COMMIT WORK.

CLEAR gt_return.
gt_return-
message = text-006 . "Attachment Done.
APPEND gt_return.

ELSE.
message = text-m07.
ENDIF.

ENDFORM. " b004_attach_pdf
*&---------------------------------------------------------------------*
*& Form SUB_BDC_DYNPRO *
*&---------------------------------------------------------------------*
* Description : This form inserts a screen call into the bdcdata *
* table *
*----------------------------------------------------------------------*
* Parameters : *
* --> P_PROG_NAME The program name *
* --> P_SCREEN_NO The screen number *
*----------------------------------------------------------------------*
FORM sub_bdc_dynpro USING p_prog_name TYPE bdc_prog
p_screen_no
TYPE bdc_dynr.

DATA: w_bdcdata LIKE bdcdata.

* Populate work area
w_bdcdata-
program = p_prog_name. " Program name
w_bdcdata-
dynpro = p_screen_no. " Screen Number
w_bdcdata-dynbegin =
'X'. " X

* Append bdc table
APPEND w_bdcdata TO gt_bdcdata.


ENDFORM. " sub_bdc_dynpro

*&---------------------------------------------------------------------*
*& Form SUB_BDC_FIELD *
*&---------------------------------------------------------------------*
* Description : This form fills the bdcdata table with the data *
* required to populate a field. *
*----------------------------------------------------------------------*
* Parameters : *
* --> P_FIELD Field name *
* --> P_VALUE Field value *
*----------------------------------------------------------------------*
FORM sub_bdc_field USING p_field TYPE fnam_____4
p_value
TYPE any.

DATA: w_bdcdata LIKE bdcdata.

* Fill the fields in the dynpro called with the correct values
w_bdcdata-fnam = p_field.
" Field Name
w_bdcdata-fval = p_value.
" Field Value

* Append bdc table
APPEND w_bdcdata TO gt_bdcdata.

ENDFORM. " sub_bdc_field
*&---------------------------------------------------------------------*
*& Form a004_display_output
*&---------------------------------------------------------------------*
* Display Report Output - Created Invoices
*----------------------------------------------------------------------*

FORM a004_display_output .

PERFORM c001_populate_field_cat.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE = ' '
* I_CALLBACK_PROGRAM = ' '
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_STRUCTURE_NAME =
* IS_LAYOUT =
it_fieldcat = gt_fieldcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IR_SALV_LIST_ADAPTER =
* IT_EXCEPT_QINFO =
* I_SUPPRESS_EMPTY_DATA = ABAP_FALSE
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = gt_main
EXCEPTIONS
program_error =
1
OTHERS = 2
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

SKIP 1.

* Listing Error Messages
LOOP AT gt_return.
WRITE:/(1) gt_return-type,
(
10) gt_return-id,
(
3) gt_return-number,
(
80) gt_return-message.
ENDLOOP.

ENDFORM. " a004_display_output
*&---------------------------------------------------------------------*
*& Form c001_populate_field_cat
*&---------------------------------------------------------------------*
* Populate Field Catelog
*----------------------------------------------------------------------*
FORM c001_populate_field_cat.

PERFORM sub_build_field_catalog USING :
'1' 'WBS' 'GT_MAIN' 'POSID' 'PRPS' '' '',
'2' 'CONTR' 'GT_MAIN' '' '' text-007 '',
'3' 'FEE_AMNT' 'GT_MAIN' 'KBETR' 'KOMV' '' '',
'4' 'EXP_AMNT' 'GT_MAIN' 'KBETR' 'KOMV' '' '',
'5' 'ORDER' 'GT_MAIN' 'VBELN' 'VBAK' '' '',
'6' 'INV' 'GT_MAIN' 'VBELN' 'VBRK' '' '',
'7' 'INV_DAT' 'GT_MAIN' '' '' text-003 '13' ,
'8' 'ACC_REL' 'GT_MAIN' '' '' text-004 '23',
'9' 'ATT_PDF' 'GT_MAIN' '' '' text-005 '23',
'10' 'MESSAGE' 'GT_MAIN' 'MESSAGE' 'BAPIRET2' '' '50'.

ENDFORM. " c001_populate_field_cat
*&---------------------------------------------------------------------*
*& Form sub_build_field_catalog
*&---------------------------------------------------------------------*
* Build Field Catalog
*----------------------------------------------------------------------*

FORM sub_build_field_catalog USING p_col_pos
p_fieldname
p_tabname
p_ref_fieldname
p_ref_tabname
p_text_l
p_outputlen.

DATA: ls_field_cat TYPE slis_fieldcat_alv.

CLEAR ls_field_cat.

ls_field_cat-col_pos = p_col_pos.
ls_field_cat-fieldname = p_fieldname.
ls_field_cat-tabname = p_tabname.
ls_field_cat-ref_fieldname = p_ref_fieldname.
ls_field_cat-ref_tabname = p_ref_tabname.
ls_field_cat-seltext_l = p_text_l.
" Long key word
ls_field_cat-outputlen = p_outputlen.

APPEND ls_field_cat TO gt_fieldcat.

ENDFORM. " sub_build_field_catalog


Comments

  1. Hi Achirangshu,

    Do you think you could post also the code for the Z_WF_DISPLAY_PDF_INVOICE FM? I need exactly the same for attaching a pdf to a sales order.

    Thanks a lot,
    Mihai

    ReplyDelete

Post a Comment

Popular posts from this blog

ABAP Tips - 1 : How to Display a Popup and Get Values from User ?

Help on BAPI_ACC_DOCUMENT_POST and BAPI_ACC_DOCUMENT_POST

Few Tips for Transport Request Manipulation