SAP AC_DOCUMENT_GENERATE Function Module for









AC_DOCUMENT_GENERATE is a standard ac document generate SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used to perform a specific ABAP function and below is the pattern details, showing its interface including any import and export parameters, exceptions etc. there is also a full "cut and paste" ABAP pattern code example, along with implementation ABAP coding, documentation and contribution comments specific to this or related objects.


See here to view full function module documentation and code listing for ac document generate FM, simply by entering the name AC_DOCUMENT_GENERATE into the relevant SAP transaction such as SE37 or SE38.

Function Group: RWCL
Program Name: SAPLRWCL
Main Program: SAPLRWCL
Appliation area: F
Release date: N/A
Mode(Normal, Remote etc): Normal Function Module
Update:



Function AC_DOCUMENT_GENERATE pattern details

In-order to call this FM within your sap programs, simply using the below ABAP pattern details to trigger the function call...or see the full ABAP code listing at the end of this article. You can simply cut and paste this code into your ABAP progrom as it is, including variable declarations.
CALL FUNCTION 'AC_DOCUMENT_GENERATE'"
EXPORTING
* I_COMP = ' ' "Component limitation
* I_COMP_CHECK = ' ' "Component limitation for checks

IMPORTING
E_AWTYP = "Object type
E_AWREF = "Object reference
E_AWORG = "Object organization
E_AWSYS = "Logical system

TABLES
T_ACCHD = "Header information
* T_ACCIT_EXT = "ACC Document: Additional Item Information
* T_AUSZ2 = "
* T_AUSZ3 = "
* T_AUSZ4 = "
* T_SPLINFO = "Splittling Information of Open Items
* T_SPLINFO_VAL = "Splitting Information of Open Item Values
T_ACCIT = "Item information
T_ACCCR = "Currency information
* T_ACCFI = "One-time account data
* T_ACCTAX = "Tax information
* T_ACCTX = "
* T_ACCIT_PA = "CO-PA: Characteristics
* T_ACCCR_PA = "
* T_ACCWT = "Withholding Tax Information for FI Interface
.


T ABAP code to create replica of SAP document using AC_DOCUMENT_GENERATE - FB01


D ABAP code to create replica of SAP document using AC_DOCUMENT_GENERATE (manually done via FB01)
& Help ABAP code to create replica of SAP document using AC_DOCUMENT_GENERATE - FB01

REPORT zm_recreate_doc.
TABLES: bseg,bkpf,cdhdr.


SELECTION-SCREEN BEGIN OF BLOCK block2 WITH FRAME TITLE text-003.
SELECT-OPTIONS:so_kunnr FOR bseg-kunnr.

SELECT-OPTIONS: so_blart FOR bkpf-blart.
SELECT-OPTIONS: so_belnr FOR bseg-belnr,
so_bukrs FOR bseg-bukrs,
so_gjahr FOR bseg-gjahr.
PARAMETER:
p_augdt TYPE bseg-augdt,
p_cputm TYPE bkpf-cputm.
SELECTION-SCREEN END OF BLOCK block2.


SELECTION-SCREEN BEGIN OF BLOCK block3 WITH FRAME TITLE text-004.
PARAMETER:p_test TYPE c AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK block3.
TYPES: BEGIN OF t_data,
kunnr TYPE bseg-kunnr,
blart TYPE bkpf-blart,
belnr TYPE bkpf-belnr,
bldat TYPE bkpf-bldat,
xblnr TYPE bkpf-xblnr,
zuonr TYPE bseg-zuonr,
dmbtr TYPE bseg-dmbtr,
xref2 TYPE bseg-xref2,
cleared TYPE c,
augbl TYPE bseg-augbl,

END OF t_data.
DATA: gt_data TYPE zfi_post_payment_tt,
wa_data TYPE zfi_post_payment_t,
gt_bseg TYPE STANDARD TABLE OF bseg,
wa_bseg LIKE LINE OF gt_bseg,
gt_bkpf TYPE STANDARD TABLE OF bkpf,
wa_bkpf TYPE bkpf,
it_post_payment TYPE STANDARD TABLE OF zfi_post_payment,
wa_post_payment TYPE zfi_post_payment,
gv_runid TYPE zfi_post_payment-runid,
lv_return TYPE char30,
wa_pp_lastrun TYPE zfi_pp_lastrun,
wa_pp_lastrun_curr TYPE zfi_pp_lastrun,
gt_variant TYPE sy-slset.

DATA: lt_acchd TYPE acchd_t,
wa_acchd TYPE acchd,
lt_accit TYPE accit_t,
wa_accit TYPE accit,
lt_acccr TYPE acccr_t,
wa_acccr TYPE acccr,
lt_accbset TYPE accbset_t,
lt_accfi TYPE STANDARD TABLE OF accfi.
DATA: it_accdn LIKE accdn OCCURS 1 WITH HEADER LINE.
* First check document to avoid drw of number and do vendor check
DATA: lt_acctax TYPE STANDARD TABLE OF acctax,
lt_accwt TYPE STANDARD TABLE OF accit_wt .

DATA: l_awref TYPE awref,
l_aworg TYPE aworg,


l_awtyp TYPE acchd-awtyp,
l_awsys TYPE acchd-awsys.
DATA: lv_posnr TYPE accit-posnr.


DATA: alv_table TYPE REF TO cl_salv_table.
DATA alv_columns TYPE REF TO cl_salv_columns_table.
DATA single_column TYPE REF TO cl_salv_column.




DATA:
gd_documentheader LIKE bapiache09,
gd_customercpd LIKE bapiacpa09,
gd_fica_hd LIKE bapiaccahd,
it_accountreceivable LIKE TABLE OF bapiacar09 WITH HEADER LINE,
it_accountgl LIKE TABLE OF bapiacgl09 WITH HEADER LINE,
it_accounttax LIKE TABLE OF bapiactx09 WITH HEADER LINE,
it_criteria LIKE TABLE OF bapiackec9 WITH HEADER LINE,
it_valuefield LIKE TABLE OF bapiackev9 WITH HEADER LINE,
it_currencyamount LIKE TABLE OF bapiaccr09 WITH HEADER LINE,
it_return LIKE TABLE OF bapiret2 WITH HEADER LINE,
it_receivers LIKE TABLE OF bdi_logsys WITH HEADER LINE,
it_fica_it LIKE TABLE OF bapiaccait WITH HEADER LINE,
it_accountpayable LIKE TABLE OF bapiacap09 WITH HEADER LINE,
it_paymentcard LIKE TABLE OF bapiacpc09 WITH HEADER LINE,
it_ext LIKE TABLE OF bapiacextc WITH HEADER LINE,
it_re LIKE TABLE OF bapiacre09 WITH HEADER LINE,
it_ext2 LIKE TABLE OF bapiparex WITH HEADER LINE.





*********************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.

PERFORM get_data_records.



*&---------------------------------------------------------------------*

*& Form GET DATA RECORDS


*&---------------------------------------------------------------------*
* text
*---------------------------------------------------------------------------------*
FORM get_data_records .
DATA: ld_objectid TYPE cdhdr-objectid,
it_cdhdr TYPE STANDARD TABLE OF cdhdr,
wa_cdhdr TYPE cdhdr,
it_cdpos TYPE STANDARD TABLE OF cdpos,
wa_cdpos TYPE cdpos.

SELECT * "belnr gjahr bukrs budat blart xblnr bldat cpudt cputm
FROM bkpf INTO CORRESPONDING FIELDS OF TABLE gt_bkpf
WHERE belnr IN so_belnr AND
bukrs IN so_bukrs AND
gjahr IN so_gjahr AND
bldat GE p_augdt AND
"aedat GE p_augdt AND
blart IN so_blart .

LOOP AT gt_bkpf INTO wa_bkpf WHERE cpudt GE p_augdt.

SELECT *
FROM bseg AS bseg
INTO CORRESPONDING FIELDS OF TABLE gt_bseg
WHERE kunnr IN so_kunnr
AND bukrs EQ wa_bkpf-bukrs
AND belnr EQ wa_bkpf-belnr
AND gjahr EQ wa_bkpf-gjahr.
IF sy-subrc EQ 0.
CLEAR: wa_acchd.
wa_acchd-bktxt = wa_bkpf-bktxt. "'TEST IDOC WITH NEW SGMENT'.
wa_acchd-tcode = 'FB01'.
wa_acchd-glvor = 'RFBU'.
wa_acchd-usnam = 'SYS_BATCH'.
wa_acchd-subset = 'GALE'.
APPEND wa_acchd TO lt_acchd.

LOOP AT gt_bseg INTO wa_bseg." WHERE kunnr IS NOT INITIAL .
" PERFORM create_reverse_doc.
PERFORM create_replicate_doc.

"PERFORM send_idoc.
"
ENDLOOP.
IF sy-subrc EQ 0.
PERFORM send_doc.
ENDIF.
ENDIF.
EXIT.
ENDLOOP.

ENDFORM. " GET_DATA_RECORDS












*&---------------------------------------------------------------------*

*& Form SEND DOC


*&---------------------------------------------------------------------*
* text
*---------------------------------------------------------------------------------*
* --> p1 text * <-- p2 text
*---------------------------------------------------------------------------------*
FORM send_doc .
CALL FUNCTION 'AC_DOCUMENT_GENERATE'
EXPORTING
i_comp = 'FI'
i_comp_check = 'FI'
IMPORTING " e_awref = l_awref
" e_aworg = l_aworg
e_awtyp = l_awtyp
e_awref = l_awref
e_aworg = l_aworg
e_awsys = l_awsys
TABLES
t_acchd = lt_acchd
t_accit = lt_accit
t_acccr = lt_acccr
t_accfi = lt_accfi
t_acctax = lt_acctax
t_acctx = lt_accbset
t_accwt = lt_accwt
EXCEPTIONS
error_message = 01
OTHERS = 02.


IF sy-subrc EQ 0 AND l_awref IS NOT INITIAL.
COMMIT WORK AND WAIT.


WRITE:/ 'awref', l_awref.
CLEAR it_accdn.
it_accdn-awtyp = l_awtyp.
it_accdn-awref = l_awref.
it_accdn-aworg = l_aworg.

APPEND it_accdn.
CALL FUNCTION 'FI_DOCUMENT_NUMBER_GET'
TABLES
t_accdn = it_accdn.



LOOP AT it_accdn.
WRITE:/ 'bel', it_accdn-belnr.
ENDLOOP.



ENDIF.
ENDFORM. " SEND_DOC
*&---------------------------------------------------------------------*

*& Form CREATE REPLICATE DOC


*&---------------------------------------------------------------------*
* text
*---------------------------------------------------------------------------------*
FORM create_replicate_doc .
CLEAR: wa_accit.
" CLEAR: wa_bseg-belnr, wa_bseg-buzei.
" MOVE-CORRESPONDING wa_bkpf TO wa_accit.
" MOVE-CORRESPONDING wa_bseg TO wa_accit.
lv_posnr = lv_posnr + 1.


wa_accit-posnr = lv_posnr.
wa_accit-bukrs = '7109'.
wa_accit-gjahr = '2024'.


wa_accit-bldat = sy-datum.
wa_accit-budat = sy-datum.
wa_accit-wwert = sy-datum.

"wa_accit-monat = '03'. "wa_bkpf-monat. "'02'.
wa_accit-blart = wa_bkpf-blart.
wa_accit-xblnr = wa_bkpf-xblnr .
wa_accit-hkont = wa_bseg-hkont.
wa_accit-mwskz = wa_bseg-mwskz.

wa_accit-bschl = wa_bseg-bschl.


wa_accit-pswsl = wa_bseg-pswsl.
wa_accit-pswbt = wa_bseg-pswbt.

wa_accit-shkzg = wa_bseg-shkzg.

IF wa_bseg-shkzg = 'H'.
MULTIPLY wa_accit-pswbt BY -1.
ENDIF.

wa_accit-koart = wa_bseg-koart. "
wa_accit-kunnr = wa_bseg-kunnr. "
wa_accit-zuonr = wa_bseg-zuonr. "
wa_accit-sgtxt = wa_bseg-sgtxt. "
wa_accit-kokrs = wa_bseg-kokrs. "
wa_accit-prctr = wa_bseg-prctr. "


wa_accit-paobjnr = wa_bseg-paobjnr. "
* wa_accit-buzid = wa_bseg-buzid. "leave blank
IF wa_bseg-buzid IS NOT INITIAL.
wa_accit-taxit = 'X'.
ENDIF.

APPEND wa_accit TO lt_accit.



CLEAR: wa_acccr.
wa_acccr-posnr = lv_posnr.
wa_acccr-waers = wa_bkpf-waers.
wa_acccr-curtp = '00'. "00 = document currency
wa_acccr-wrbtr = wa_accit-pswbt.
wa_acccr-fwbas = wa_bseg-fwbas.
APPEND wa_acccr TO lt_acccr.
ENDFORM. " CREATE_REPLICATE_DOC


IMPORTING Parameters details for AC_DOCUMENT_GENERATE

I_COMP - Component limitation

Data type: TRWPR-COMPONENT
Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)

I_COMP_CHECK - Component limitation for checks

Data type: TRWPR-COMPONENT
Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)

EXPORTING Parameters details for AC_DOCUMENT_GENERATE

E_AWTYP - Object type

Data type: ACCHD-AWTYP
Optional: No
Call by Reference: No ( called with pass by value option)

E_AWREF - Object reference

Data type: ACCHD-AWREF
Optional: No
Call by Reference: No ( called with pass by value option)

E_AWORG - Object organization

Data type: ACCHD-AWORG
Optional: No
Call by Reference: No ( called with pass by value option)

E_AWSYS - Logical system

Data type: ACCHD-AWSYS
Optional: No
Call by Reference: No ( called with pass by value option)

TABLES Parameters details for AC_DOCUMENT_GENERATE

T_ACCHD - Header information

Data type: ACCHD
Optional: No
Call by Reference: No ( called with pass by value option)

T_ACCIT_EXT - ACC Document: Additional Item Information

Data type: ACCIT_EXTENSION
Optional: Yes
Call by Reference: Yes

T_AUSZ2 -

Data type: AUSZ2
Optional: Yes
Call by Reference: Yes

T_AUSZ3 -

Data type: AUSZ_CLR
Optional: Yes
Call by Reference: Yes

T_AUSZ4 -

Data type: AUSZ_CLR_ASGMT
Optional: Yes
Call by Reference: Yes

T_SPLINFO - Splittling Information of Open Items

Data type: FAGL_S_ALE_SPLINFO
Optional: Yes
Call by Reference: Yes

T_SPLINFO_VAL - Splitting Information of Open Item Values

Data type: FAGL_SPLINFO_VAL
Optional: Yes
Call by Reference: Yes

T_ACCIT - Item information

Data type: ACCIT
Optional: No
Call by Reference: No ( called with pass by value option)

T_ACCCR - Currency information

Data type: ACCCR
Optional: No
Call by Reference: No ( called with pass by value option)

T_ACCFI - One-time account data

Data type: ACCFI
Optional: Yes
Call by Reference: No ( called with pass by value option)

T_ACCTAX - Tax information

Data type: ACCTAX
Optional: Yes
Call by Reference: No ( called with pass by value option)

T_ACCTX -

Data type: ACCBSET
Optional: Yes
Call by Reference: No ( called with pass by value option)

T_ACCIT_PA - CO-PA: Characteristics

Data type: ACCIT_PA
Optional: Yes
Call by Reference: No ( called with pass by value option)

T_ACCCR_PA -

Data type: ACCCR_PA
Optional: Yes
Call by Reference: No ( called with pass by value option)

T_ACCWT - Withholding Tax Information for FI Interface

Data type: ACCIT_WT
Optional: Yes
Call by Reference: Yes

Copy and paste ABAP code example for AC_DOCUMENT_GENERATE Function Module

The ABAP code below is a full code listing to execute function module POPUP_TO_CONFIRM including all data declarations. The code uses the original data declarations rather than the latest in-line data DECLARATION SYNTAX but I have included an ABAP code snippet at the end to show how declarations would look using the newer method of declaring data variables on the fly. This will allow you to compare and fully understand the new inline method. Please note some of the newer syntax such as the @DATA is not available until a later 4.70 service pack (SP8), which i why i have stuck to the origianl for this example.

DATA:
lv_i_comp  TYPE TRWPR-COMPONENT, "   SPACE
lv_e_awtyp  TYPE ACCHD-AWTYP, "   
lt_t_acchd  TYPE STANDARD TABLE OF ACCHD, "   
lt_t_accit_ext  TYPE STANDARD TABLE OF ACCIT_EXTENSION, "   
lt_t_ausz2  TYPE STANDARD TABLE OF AUSZ2, "   
lt_t_ausz3  TYPE STANDARD TABLE OF AUSZ_CLR, "   
lt_t_ausz4  TYPE STANDARD TABLE OF AUSZ_CLR_ASGMT, "   
lt_t_splinfo  TYPE STANDARD TABLE OF FAGL_S_ALE_SPLINFO, "   
lt_t_splinfo_val  TYPE STANDARD TABLE OF FAGL_SPLINFO_VAL, "   
lv_e_awref  TYPE ACCHD-AWREF, "   
lt_t_accit  TYPE STANDARD TABLE OF ACCIT, "   
lv_i_comp_check  TYPE TRWPR-COMPONENT, "   SPACE
lv_e_aworg  TYPE ACCHD-AWORG, "   
lt_t_acccr  TYPE STANDARD TABLE OF ACCCR, "   
lv_e_awsys  TYPE ACCHD-AWSYS, "   
lt_t_accfi  TYPE STANDARD TABLE OF ACCFI, "   
lt_t_acctax  TYPE STANDARD TABLE OF ACCTAX, "   
lt_t_acctx  TYPE STANDARD TABLE OF ACCBSET, "   
lt_t_accit_pa  TYPE STANDARD TABLE OF ACCIT_PA, "   
lt_t_acccr_pa  TYPE STANDARD TABLE OF ACCCR_PA, "   
lt_t_accwt  TYPE STANDARD TABLE OF ACCIT_WT. "   

  CALL FUNCTION 'AC_DOCUMENT_GENERATE'  "
    EXPORTING
         I_COMP = lv_i_comp
         I_COMP_CHECK = lv_i_comp_check
    IMPORTING
         E_AWTYP = lv_e_awtyp
         E_AWREF = lv_e_awref
         E_AWORG = lv_e_aworg
         E_AWSYS = lv_e_awsys
    TABLES
         T_ACCHD = lt_t_acchd
         T_ACCIT_EXT = lt_t_accit_ext
         T_AUSZ2 = lt_t_ausz2
         T_AUSZ3 = lt_t_ausz3
         T_AUSZ4 = lt_t_ausz4
         T_SPLINFO = lt_t_splinfo
         T_SPLINFO_VAL = lt_t_splinfo_val
         T_ACCIT = lt_t_accit
         T_ACCCR = lt_t_acccr
         T_ACCFI = lt_t_accfi
         T_ACCTAX = lt_t_acctax
         T_ACCTX = lt_t_acctx
         T_ACCIT_PA = lt_t_accit_pa
         T_ACCCR_PA = lt_t_acccr_pa
         T_ACCWT = lt_t_accwt
. " AC_DOCUMENT_GENERATE




ABAP code using 7.40 inline data declarations to call FM AC_DOCUMENT_GENERATE

The below ABAP code uses the newer in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. Please note some of the newer syntax below, such as the @DATA is not available until 4.70 EHP 8.

"SELECT single COMPONENT FROM TRWPR INTO @DATA(ld_i_comp).
DATA(ld_i_comp) = ' '.
 
"SELECT single AWTYP FROM ACCHD INTO @DATA(ld_e_awtyp).
 
 
 
 
 
 
 
 
"SELECT single AWREF FROM ACCHD INTO @DATA(ld_e_awref).
 
 
"SELECT single COMPONENT FROM TRWPR INTO @DATA(ld_i_comp_check).
DATA(ld_i_comp_check) = ' '.
 
"SELECT single AWORG FROM ACCHD INTO @DATA(ld_e_aworg).
 
 
"SELECT single AWSYS FROM ACCHD INTO @DATA(ld_e_awsys).
 
 
 
 
 
 
 


Search for further information about these or an SAP related objects



Comments on this SAP object

What made you want to lookup this SAP object? Please tell us what you were looking for and anything you would like to be included on this page!