SAP data migration: Create billing plan for sales

Source: Internet
Author: User

Reference: skysky

Report zup2
No standard page heading line-size 255.

 

* Include bdcrecx1.
Parameters: DataSet like RLGRAP-FILENAME.
Parameters: p_mode like CTU_PARAMS-DISMODE default 'E '.
* Batchinputdata of single transaction
Data: bdcdata like bdcdata occurs 0 with header line.
* Messages of call transaction
Data: messtab like bdcmsgcoll occurs 0 with header line.
*
* ** Generated data section with specific formatting-do not change ***
Data: Begin of record,
Vbeln (030 ),
Posnr (006 ),
Mlbez (005 ),
Waers (005 ),
Faksp (002 ),
Fareg (001 ),
Fksaf (001 ),
Fpttp (002 ),
Fkarv (004 ),
Mlstn (012 ),
Fpfix (001 ),
Afdat (010 ),
Fproz (010 ),
Fakwr (025 ),
End of record.
Data: itab like standard table of record with header line.
Data: temp like standard table of record with header line.
* ** End generated data section ***
Start-of-selection.
Perform upload_file.
Check not itab [] is initial.
Sort itab by vbeln posnr.
Loop at itab.
Record = itab.
Temp = record.
Append temp.
* The first sales document, step into the first screen
At New vbeln.
Perform bdc_dynpro using 'sapmv45a' '000000 '.
Perform bdc_field using 'bdc _ cursor'
'Vbak-vbeln '.
Perform bdc_field using 'bdc _ okcode'
'/00 '.
Perform bdc_field using 'vbak-vbeln'
Record-vbeln.
Endat.
* A new item input, follow the second screen
At end of posnr.
Perform bdc_dynpro using 'sapmv45a' '000000 '.
Perform bdc_field using 'bdc _ okcode'
'= Popopo '.
Perform bdc_dynpro using 'sapmv45a' '000000 '.
Perform bdc_field using 'bdc _ cursor'
'Rv45a-posnr '.
Perform bdc_field using 'bdc _ okcode'
'= Posi '.
Perform bdc_field using 'rv45a-posnr'
RECORD-POSNR.
Perform bdc_dynpro using 'sapmv45a' '000000 '.
Perform bdc_field using 'bdc _ okcode'
'= Item '.
Perform bdc_field using 'bdc _ cursor'
'Vbap-posnr (01 )'.
Perform bdc_dynpro using 'sapmv45a' '000000 '.
Perform bdc_field using 'bdc _ okcode'
'= T \ 05 '.
* Process the billing plan
Loop at temp.
Perform bdc_dynpro using 'saplv60f' '000000 '.
Perform bdc_field using 'bdc _ okcode'
'= Anle '.
Perform bdc_field using 'bdc _ cursor'
'Fplt-afdat (02 )'.
Perform bdc_field using 'fplt-afdat (02 )'
TEMP-AFDAT.
Perform bdc_field using 'fplt-mlbez (02 )'
TEMP-MLBEZ.
* Perform bdc_field using 'fplt-waers (02 )'
* TEMP-WAERS.
Perform bdc_field using 'fplt-faksp (02 )'
TEMP-FAKSP.
Perform bdc_field using 'fplt-fareg (02 )'
TEMP-FAREG.
* Perform bdc_field using 'fplt-fksaf (02 )'
* TEMP-FKSAF.
Perform bdc_field using 'fplt-fpttp (02 )'
TEMP-FPTTP.
Perform bdc_field using 'fplt-fkarv (02 )'
TEMP-FKARV.
* Perform bdc_field using 'fplt-mlstn (02 )'
* TEMP-MLSTN.
Perform bdc_field using 'fplt-fpfix (02 )'
TEMP-FPFIX.
Perform bdc_field using 'fplt-fproz (02 )'
TEMP-FPROZ.
Perform bdc_field using 'fplt-fakwr (02 )'
TEMP-FAKWR.
Endloop.
* Leave to item Screen
Perform bdc_dynpro using 'saplv60f' '000000 '.
Perform bdc_field using 'bdc _ okcode'
'= T \ 01 '.
Perform bdc_dynpro using 'sapmv45a' '000000 '.
Perform bdc_field using 'bdc _ okcode'
'/Eback '.
Clear: temp, temp [].
Endat.
* A sales docu end, save the changes
At end of vbeln.
Perform bdc_dynpro using 'sapmv45a' '000000 '.
Perform bdc_field using 'bdc _ okcode'
'= Sich '.
Perform bdc_dynpro using 'saplspo2 ''123 '.
Perform bdc_field using 'bdc _ okcode'
'= Opt1 '.
Call transaction 'va02' using bdcdata
Mode p_mode
Update's'
Messages into messtab.
Read Table messtab with key msgtyp = 'E '.
If SY-SUBRC = 0.
Write:/record-vbeln.
Endif.
Clear: bdcdata, bdcdata [].
Endat.
Endloop.
*&---------------------------------------------------------------------*
* & Form upload_file
*&---------------------------------------------------------------------*
* Text
*----------------------------------------------------------------------*
* --> P_dataset text
*----------------------------------------------------------------------*
Form upload_file.
Call function 'ws _ upload'
Exporting
Filename = Dataset
Filetype = 'dat'
Tables
Data_tab = itab
Exceptions
Conversion_error = 1
File_open_error = 2
File_read_error = 3
Invalid_type = 4
No_batch = 5
Unknown_error = 6
Invalid_table_width = 7
Gui_refuse_filetransfer = 8
Customer_error = 9
Others = 10
.
Endform. "upload_file
*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
Form bdc_dynpro using program dynpro.
Clear bdcdata.
BDCDATA-PROGRAM = program.
BDCDATA-DYNPRO = dynpro.
BDCDATA-DYNBEGIN = 'x '.
Append bdcdata.
Endform.
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
Form bdc_field using FNAM fval.
If fval <> space.
Clear bdcdata.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = fval.
Append bdcdata.
Endif.
Endform.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.