06-19-2008 11:53 PM
Hi,
I am writing one BDC program to park document( not posting the document) using transaction u2018FBV1u2019.In the file, we can have multiple item for posting key 40 and single item for posting key 50 and vice-versa. We can have multiple item both for posting key 40 and 50. But the summation of all amount of all record for posting key 40 and 50 should be u20180u2019( for debit and credit).All these multiple records is actually creating one account document.
I have created the recording and written the BDC program, but I hope I am missing the grouping of records for posting key 40 and 50 for single document number. Can pls guide me for the same. If anyone has encountered such problem, can you pls guide me for the same. If you haave the code for BDC, please send me the same.
Edited by: amrita banerjee on Jun 20, 2008 12:53 AM
06-20-2008 12:03 AM
Hi amrita,
I do not understand what do you mean by grouping of records. Can you please explain.
Still for parking documents, the recommended solution will be to use the standard batch input program RFBIBL00.
Here is the sample psedo-code
****************************************************************************
*bgr00
wa_bgr00-stype = 0.
CONCATENATE 'FBV1' sy-uzeit+0(2) '_' sy-uzeit+4(2)
INTO wa_bgr00-group.
wa_bgr00-mandt = sy-mandt.
wa_bgr00-usnam = sy-uname.
wa_bgr00-start = sy-datum.
wa_bgr00-xkeep = space.
wa_bgr00-nodata = '/'.
MOVE wa_bgr00 TO wa_file.
APPEND wa_file TO it_file.
v_empty_indicator = wa_bgr00-nodata .
****************************************************************************
*bbkpf
PERFORM build_data CHANGING wa_bbkpf.
wa_bbkpf-stype = 1.
wa_bbkpf-tcode = 'FBV1'.
wa_bbkpf-bldat = wa_docheader-doc_date.
wa_bbkpf-blart = wa_docheader-doc_type.
wa_bbkpf-bukrs = wa_docheader-comp_code.
wa_bbkpf-budat = wa_docheader-pstng_date.
wa_bbkpf-monat = wa_docheader-fis_period.
wa_bbkpf-waers = 'USD'.
wa_bbkpf-xblnr = wa_docheader-ref_doc_no.
wa_bbkpf-bktxt = wa_docheader-header_txt.
MOVE wa_bbkpf TO wa_file.
APPEND wa_file TO it_file.
****************************************************************************
*bbseg
LOOP AT it_accntgl INTO wa_accntgl.
CLEAR wa_bbseg.
PERFORM build_data CHANGING wa_bbseg.
READ TABLE it_curramount INTO wa_curramount INDEX wa_accntgl-itemno_acc.
wa_bbseg-stype = '2'.
wa_bbseg-tbnam = 'BBSEG'.
wa_bbseg-zuonr = wa_accntgl-alloc_nmbr.
wa_bbseg-newbk = wa_accntgl-comp_code.
wa_bbseg-wrbtr = wa_curramount-amt_doccur.
wa_bbseg-kostl = wa_accntgl-costcenter.
wa_bbseg-aufnr = wa_accntgl-orderid.
wa_bbseg-hkont = wa_accntgl-gl_account.
wa_bbseg-prctr = wa_accntgl-profit_ctr..
wa_bbseg-projk = wa_accntgl-wbs_element.
IF wa_curramount-amt_doccur LT 0.
wa_bbseg-newbs = '40'.
ELSE.
wa_bbseg-newbs = '50'.
ENDIF.
MOVE wa_bbseg TO wa_file.
APPEND wa_file TO it_file.
ENDLOOP.
DATA: l_filepath TYPE eseftappl.
CONCATENATE '/tmp/FBV1_load' sy-uzeit '.txt' INTO l_filepath.
*write app file for rfbibl00
PERFORM write_data_appl USING it_file l_filepath.
*Submit the data to post the document
SUBMIT rfbibl00 WITH ds_name = l_filepath
WITH fl_check = ' '
WITH callmode = 'C'
WITH xinf = 'X'
AND RETURN.
form build_data changing pv_header TYPE any.
DATA:
v_field(3) TYPE n.
FIELD-SYMBOLS <fs_field_value> TYPE ANY.
v_field = 1.
DO.
ASSIGN COMPONENT v_field OF STRUCTURE pv_header TO <fs_field_value>.
IF sy-subrc = 0.
* if the field is empty then fill it with nodata indicatort
IF <fs_field_value> IS INITIAL.
<fs_field_value> = v_empty_indicator.
ENDIF.
v_field = v_field + 1.
ELSE.
EXIT.
ENDIF.
ENDDO.
endform. " build_data
form write_data_appl USING pv_file TYPE ty_t_filedata
pv_file_path TYPE eseftappl.
DATA:
wa_file TYPE ty_filedata,
wa_return TYPE bapiret2,
v_msg TYPE string.
*Open the application server file
*and write the data
OPEN DATASET pv_file_path FOR OUTPUT
IN TEXT MODE ENCODING NON-UNICODE
MESSAGE v_msg.
IF sy-subrc = 0.
* write the file to the application server
LOOP AT pv_file INTO wa_file.
TRANSFER wa_file TO pv_file_path.
ENDLOOP.
CLOSE DATASET pv_file_path.
ELSE.
message e000(00) with v_msg.
ENDIF.
endform. " write_data_appl
Thanks
Romit
06-20-2008 12:14 AM
Thanks For your mail.
But looking into the syntax, can you tell me the process flow of your program? Are not you picking up the flat/test/data file fro m presentation server or anywhere? why are placing the file into appl server?
more over that, if i wanna use profiatability segments values like FLAVOR, BRAND, PRODUCT etc instead of cost center or Internal order number, is this standard program going to solve the problem..
thanks again..
06-20-2008 12:27 AM
Yes, that just a snapshot of the whole program. We need to write the file on application server as the program RFBIBLO requires the input as file. For more information please read the documentation for the program RFBIBLO.
You can use the BBSEG structure for profitability segement fields. Again, please check the documentation.
Do rewards points if you find this useful.
Thanks
Romit
Edited by: Romit Kewalramani on Jun 20, 2008 1:40 AM