Posted: Tue Oct 23, 2007 10:37 am Post subject: Создание основного средства с BAPI_FIXEDASSET_OVRTAKE_CREATE
Code:
FORM map_fixassets CHANGING p_input_table TYPE t_input_table
p_asset_table TYPE t_asset_table
p_cost_table TYPE t_cost_table
p_depr_table TYPE t_depr_table
p_error_table TYPE t_error_table
p_t093c TYPE t_t093c_table
p_csks TYPE t_csks_table.
DATA:
l_testrun TYPE bapi1022_misc-testrun,
la_generaldata TYPE bapi1022_feglg001,
la_generaldatax TYPE bapi1022_feglg001x,
la_inventory TYPE bapi1022_feglg011,
la_inventoryx TYPE bapi1022_feglg011x,
la_postinginformation TYPE bapi1022_feglg002,
la_postinginformationx TYPE bapi1022_feglg002x,
la_key TYPE bapi1022_key,
la_timedependentdata TYPE bapi1022_feglg003,
la_timedependentdatax TYPE bapi1022_feglg003x,
la_allocations TYPE bapi1022_feglg004,
la_allocationsx TYPE bapi1022_feglg004x,
la_origin TYPE bapi1022_feglg009,
la_originx TYPE bapi1022_feglg009x,
la_assetcreated TYPE bapi1022_reference,
li_depreciationareas TYPE TABLE OF bapi1022_dep_areas,
la_depreciationareas LIKE LINE OF li_depreciationareas,
li_depreciationareasx TYPE TABLE OF bapi1022_dep_areasx,
la_depreciationareasx LIKE LINE OF li_depreciationareasx,
li_cumulatedvalues TYPE TABLE OF bapi1022_cumval,
la_cumulatedvalues LIKE LINE OF li_cumulatedvalues,
li_postedvalues TYPE TABLE OF bapi1022_postval,
la_postedvalues LIKE LINE OF li_postedvalues,
li_transactions TYPE TABLE OF bapi1022_trtype,
la_transactions LIKE LINE OF li_transactions.
IF p_create = 'X'. "Determine whether testrun or actual run.
l_testrun = space.
ELSE.
l_testrun = 'X'.
ENDIF.
SORT p_asset_table BY lclass.
SORT p_cost_table BY ldept.
SORT p_depr_table BY ldepr.
SORT p_t093c BY bukrs.
SORT p_csks BY kostl.
LOOP AT p_input_table INTO wa_input.
CLEAR: l_anlkl,
l_flag.
g_no_read = g_no_read + 1.
* To pick up the asset class from the asset class file corresponding to the legacy class
READ TABLE p_asset_table INTO wa_asset
BINARY SEARCH WITH KEY lclass = wa_input-lclass.
* To pick up the cost center from cost center file corresponding to legacy dept
READ TABLE p_cost_table INTO wa_cost
BINARY SEARCH WITH KEY ldept = wa_input-kostl.
IF sy-subrc = 0.
* To validate company code
READ TABLE p_t093c INTO wa_t093c BINARY SEARCH WITH KEY bukrs = wa_cost-bukrs.
IF sy-subrc <> 0. "company code not valid
IF l_flag <> 'X'.
MOVE-CORRESPONDING wa_input TO wa_error_file.
l_flag = 'X'.
wa_error_file-mssg1 = text-029.
ELSE.
CONCATENATE wa_error_file-mssg1 text-029
INTO wa_error_file-mssg1 SEPARATED BY ','.
* wa_error_file-mssg2 = text-029.
ENDIF.
ELSE.
la_key-companycode = wa_cost-bukrs.
ENDIF.
* to validate cost centre
READ TABLE p_csks INTO wa_csks BINARY SEARCH WITH KEY kostl = wa_cost-kostl.
IF sy-subrc <> 0. "cost center not valid
IF l_flag <> 'X'.
MOVE-CORRESPONDING wa_input TO wa_error_file.
l_flag = 'X'.
wa_error_file-mssg1 = text-030.
ELSE.
CONCATENATE wa_error_file-mssg1 text-030
INTO wa_error_file-mssg1 SEPARATED BY ','.
ENDIF.
* for depr 01
* To pick up the depr key from dept input file corresponding to legacy depr key
READ TABLE p_depr_table INTO wa_depr
BINARY SEARCH WITH KEY ldepr = wa_input-afasl_01.
IF l_flag <> 'X'.
MOVE-CORRESPONDING wa_input TO wa_error_file.
l_flag = 'X'.
CONCATENATE wa_input-afasl_01 text-110 '01'
INTO wa_error_file-mssg1 SEPARATED BY ','.
ELSE.
CONCATENATE wa_error_file-mssg1 wa_input-afasl_01 text-110 '01'
INTO wa_error_file-mssg1 SEPARATED BY ','.
ENDIF.
ENDIF.
* for depr 10
* To pick up the depr key from dept input file corresponding to legacy depr key
READ TABLE p_depr_table INTO wa_depr
BINARY SEARCH WITH KEY ldepr = wa_input-afasl_10.
IF l_flag <> 'X'.
MOVE-CORRESPONDING wa_input TO wa_error_file.
l_flag = 'X'.
CONCATENATE wa_input-afasl_10 text-110 '10'
INTO wa_error_file-mssg1 SEPARATED BY ','.
ELSE.
CONCATENATE wa_error_file-mssg1 wa_input-afasl_10 text-110 '10'
INTO wa_error_file-mssg1 SEPARATED BY ','.
ENDIF.
ENDIF.
* for depr 11
* To pick up the depr key from dept input file corresponding to legacy depr key
READ TABLE p_depr_table INTO wa_depr
BINARY SEARCH WITH KEY ldepr = wa_input-afasl_11.
IF l_flag <> 'X'.
MOVE-CORRESPONDING wa_input TO wa_error_file.
l_flag = 'X'.
CONCATENATE wa_input-afasl_11 text-110 '11'
INTO wa_error_file-mssg1 SEPARATED BY ','.
ELSE.
CONCATENATE wa_error_file-mssg1 wa_input-afasl_11 text-110 '11'
INTO wa_error_file-mssg1 SEPARATED BY ','.
ENDIF.
ENDIF.
* for depr 30
* To pick up the depr key from dept input file corresponding to legacy depr key
READ TABLE p_depr_table INTO wa_depr
BINARY SEARCH WITH KEY ldepr = wa_input-afasl_30.
la_cumulatedvalues-ord_dep = wa_input-acc_ord_depr_30.
APPEND la_cumulatedvalues TO li_cumulatedvalues.
CLEAR: la_cumulatedvalues.
*Begin of MOD001-
* la_postedvalues-area = wa_input-afabe_30.
* la_postedvalues-ord_dep = wa_input-ord_depr_post_30.
* APPEND la_postedvalues TO li_postedvalues.
* CLEAR: la_postedvalues.
*End of MOD001-
ELSE.
IF l_flag <> 'X'.
MOVE-CORRESPONDING wa_input TO wa_error_file.
l_flag = 'X'.
CONCATENATE wa_input-afasl_30 text-110 '30'
INTO wa_error_file-mssg1 SEPARATED BY ','.
ELSE.
CONCATENATE wa_error_file-mssg1 wa_input-afasl_30 text-110 '30'
INTO wa_error_file-mssg1 SEPARATED BY ','.
ENDIF.
ENDIF.
* for depr 40
* To pick up the depr key from dept input file corresponding to legacy depr key
READ TABLE p_depr_table INTO wa_depr
BINARY SEARCH WITH KEY ldepr = wa_input-afasl_40.
CONCATENATE text-009 la_assetcreated-asset
INTO l_message.
CLEAR: la_assetcreated.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ELSE.
l_message = text-064.
ENDIF.
EXIT.
ELSE.
IF l_message IS INITIAL.
CONCATENATE l_message wa_return-message INTO l_message.
ELSE.
CONCATENATE l_message wa_return-message INTO l_message SEPARATED BY ','.
ENDIF.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.