SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

BAPI_PROFITCENTER_CREATE



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Interfaces | Интерфейсы -> BAPI
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1637

PostPosted: Sat Jan 31, 2009 4:54 pm    Post subject: BAPI_PROFITCENTER_CREATE Reply with quote

BAPI_PROFITCENTER_CREATE

Code:
*&---------------------------------------------------------------------*
*& Report ZDCFI0002
*&
*&---------------------------------------------------------------------*
*& Author: Patrick Guo
*& Date : 19 Dec 2006
*&---------------------------------------------------------------------*

report zdcfi0002.

data: begin of itab occurs 0,
prctr like prct_v-prctr,
ref_kokrs like prct_v-ref_kokrs,
datab(8),
datbi(8),
ktext like prct_v-ktext,
ltext like prct_v-ltext,
verak like prct_v-verak,
khinr like prct_v-khinr,
end of itab.

data: profitcenterid like bapi0015id2,
validfrom like bapi0015_3-date,
validto like bapi0015_3-date,
basicdata like bapi0015_4,
language like bapi0015_10.

data: return like bapiret2,
profitcenter like bapi0015id2-profit_ctr,
controllingarea like bapi0015id2-co_area.

data: companycodes like bapi0015_7 occurs 0 with header line.

data: wait like bapita-wait value 'X',
creturn like bapiret2.

data: filetab type filetable,
wa_filetab like file_table,
returncode type i,
count type i,
okrecord type i,
failrecord type i.

data: n_prctr(10) type n.

parameters: r1 radiobutton group g1,
r2 radiobutton group g1.
parameters: codepage type abap_encod default '4110'.
parameters: pmode type c default 'N' obligatory.

include zindc0001.

start-of-selection.

perform read_file.
if r1 = 'X'.
perform form_create.
else.
perform form_change.
endif.



*&---------------------------------------------------------------------*
*& Form read_file
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form read_file .
types: infile type ref to cl_gui_frontend_services.

data: gfile type infile,
fname type string.
create object gfile.
gfile->file_open_dialog( changing file_table = filetab
rc = returncode ).
read table filetab into wa_filetab index 1.
move wa_filetab-filename to fname.

call function 'GUI_UPLOAD'
exporting
filename = fname
filetype = 'ASC'
has_field_separator = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
codepage = codepage
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
tables
data_tab = itab
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.

endform. " read_file
*&---------------------------------------------------------------------*
*& Form form_create
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form form_create .
clear: count, n_prctr.
loop at itab from 2.
add 1 to count.
n_prctr = itab-prctr.
itab-prctr = n_prctr.
clear: profitcenterid, basicdata, language.
refresh: companycodes.
profitcenterid-co_area = itab-ref_kokrs.
profitcenterid-profit_ctr = itab-prctr.
*PROFITCENTERID = itab-REF_KOKRS.
*PROFITCENTER = itab-PRCTR.
validfrom = itab-datab.
validto = itab-datbi.
basicdata-prctr_name = itab-ktext.
basicdata-long_text = itab-ltext.
basicdata-in_charge = itab-verak.
basicdata-prctr_hier_grp = itab-khinr.
language-langu = 'EN'.

companycodes-comp_code = itab-khinr.
companycodes-assign_to_prctr = 'X'.
append companycodes.

call function 'BAPI_PROFITCENTER_CREATE'
exporting
profitcenterid = profitcenterid
validfrom = validfrom
validto = validto
basicdata = basicdata
* ADDRESS =
* COMMUNICATION =
* INDICATORS =
* TESTRUN =
language = language
importing
return = return
profitcenter = profitcenter
controllingarea = controllingarea
tables
companycodes = companycodes
.


*CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* WAIT = WAIT
* IMPORTING
* RETURN = CRETURN
if return-type = 'E'.
format color col_negative.
write: / count, return-message+0(60).
format color off.
else.
write: / count, return-message+0(60).
endif.

endloop.
endform. " form_create
*&---------------------------------------------------------------------*
*& Form form_change
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form form_change .
opt-dismode = pmode.
opt-defsize = 'X'.
opt-updmode = 'S'.

loop at itab from 2.
add 1 to count.
set parameter id 'CAC' field itab-ref_kokrs.
set parameter id 'PRC' field itab-prctr.
refresh: bdctab, msg_tab.

perform fill_bdcdata
using: 'SAPLRKPM' '0298' 'X' '' '',
'' '' '' 'PRCT_V-KTEXT' itab-ktext,
'' '' '' 'PRCT_V-LTEXT' itab-ltext,
'' '' '' 'BDC_OKCODE' '=MD_SAVE'.

call transaction 'KE52' using bdctab messages into msg_tab options from opt.
select single * from t100 where sprsl = sy-langu
and arbgb = sy-msgid
and msgnr = sy-msgno.
if sy-subrc = 0.
replace '&1' in t100-text with sy-msgv1.
replace '&2' in t100-text with sy-msgv2.
replace '&3' in t100-text with sy-msgv3.
replace '&4' in t100-text with sy-msgv4.
if sy-msgty = 'E'.
format color col_negative.
write: / count, t100-text.
format color off.
else.
if sy-msgty = '00359'.
else.
okrecord = okrecord + 1.
endif.
write: / count, t100-text.
endif.
endif.
endloop.
failrecord = count - okrecord.
write: /.
write: / 'Total record need to be proceeded = ', count.
write: / 'Total successed record = ', okrecord.
write: / 'Total not successed record = ', failrecord.

endform. " form_change
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Interfaces | Интерфейсы -> BAPI All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
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 can 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.