DATA: BEGIN OF bdc_tab OCCURS 0.
INCLUDE STRUCTURE bdcdata.
DATA: END OF bdc_tab.
DATA : type LIKE rlgrap-filetype VALUE 'DAT',
length(5),
file LIKE rlgrap-filename VALUE 'D:TEMPWBS_GEN.TXT'.
DATA : BEGIN OF s_field,
stufe(40),
ident(40),
post1(40),
plakz(40), " 계획요소
fakkz(40), " 원가(Acct)
belkz(40), " 청구(Billing)
END OF s_field.
DATA : n_line(2) TYPE n.
DATA : BEGIN OF it_data OCCURS 0,
chk(1) , " Flag
pspid(24) , " 현장 코드
stufe(10) , " 레벨
wbs(40) , " WBS코드
post1(40) , " WBS명
accounting(10) , " 원가투입
billing(10) , " 대금청구
planning(10) , " 계획요소
END OF it_data.
************************
* Start-of-Selection *
************************
START-OF-SELECTION.
CALL FUNCTION 'UPLOAD'
EXPORTING
filename = file
filetype = type
IMPORTING
filesize = length
TABLES
data_tab = it_data.
DELETE it_data WHERE chk = '@'.
DELETE it_data WHERE pspid IS INITIAL.
LOOP AT it_data.
AT NEW pspid.
CLEAR bdc_tab.
REFRESH bdc_tab.
PERFORM dynpro_bdc_tab USING :
'X' 'SAPLCJTR' '0108',
' ' 'BDC_OKCODE' '/00',
' ' 'PROJ-PSPID' it_data-pspid,
' ' 'PRPS-POSID' ' ',
'X' 'SAPLCJTR' '0230',
' ' 'BDC_OKCODE' '=TBPG'.
PERFORM dynpro_bdc_tab USING :
'X' 'SAPLCJWB' '0901',
' ' 'BDC_OKCODE' '=BU'.
n_line = 0.
ENDAT.
n_line = n_line + 1.
CONCATENATE 'PRPS-STUFE(' n_line ')' INTO s_field-stufe.
CONCATENATE 'RCWBS-IDENT(' n_line ')' INTO s_field-ident.
CONCATENATE 'PRPS-POST1(' n_line ')' INTO s_field-post1.
CONCATENATE 'PRPS-PLAKZ(' n_line ')' INTO s_field-plakz.
CONCATENATE 'PRPS-FAKKZ(' n_line ')' INTO s_field-fakkz.
CONCATENATE 'PRPS-BELKZ(' n_line ')' INTO s_field-belkz.
PERFORM dynpro_bdc_tab USING :
' ' s_field-stufe it_data-stufe,
' ' s_field-ident it_data-wbs,
' ' s_field-post1 it_data-post1,
' ' s_field-plakz it_data-planning,
' ' s_field-belkz it_data-accounting,
' ' s_field-fakkz it_data-billing.
AT END OF pspid.
CALL TRANSACTION 'CJ20'
USING bdc_tab
* MODE 'A'
MODE 'E'
UPDATE 'S'.
ENDAT.
ENDLOOP.
*-- 정산규칙 설정...
LOOP AT it_data.
AT NEW pspid.
CLEAR bdc_tab.
REFRESH bdc_tab.
PERFORM dynpro_bdc_tab USING :
'X' 'SAPLCJTR' '0108',
' ' 'BDC_OKCODE' '=STTR',
' ' 'PROJ-PSPID' it_data-pspid,
' ' 'PRPS-POSID' ' ',
'X' 'SAPLCJTR' '0230',
' ' 'BDC_OKCODE' '=TBPG',
'X' 'SAPLCJWB' '0901',
' ' 'BDC_OKCODE' '=MRKA',
'X' 'SAPLCJWB' '0901',
' ' 'BDC_OKCODE' '=ABRV'.
n_line = 0.
ENDAT.
n_line = n_line + 1.
PERFORM dynpro_bdc_tab USING :
'X' 'SAPLKOBS' '0130',
' ' 'BDC_OKCODE' '/00',
' ' 'COBRB-KONTY(01)' 'PSG',
'X' 'SAPLKEAK' '0300',
' ' 'BDC_OKCODE' '=WEIT',
'X' 'SAPLKOBS' '0130',
' ' 'BDC_OKCODE' '=KOAP',
' ' 'COBRB-PERBZ(01)' 'FUL',
'X' 'SAPLSPO4' '0300',
' ' 'BDC_OKCODE' '=FURT',
' ' 'SVALD-VALUE(01)' '10',
'X' 'SAPLKOBS' '0130',
' ' 'BDC_OKCODE' '/00',
' ' 'COBRB-KONTY(01)' 'PSG',
'X' 'SAPLKEAK' '0300',
' ' 'BDC_OKCODE' '=WEIT',
'X' 'SAPLKOBS' '0130',
' ' 'BDC_OKCODE' '=KOAO',
'X' 'SAPLKOBS' '0130',
' ' 'BDC_OKCODE' '=NOBJ'.
AT END OF pspid.
PERFORM dynpro_bdc_tab USING :
'X' 'SAPLCJWB' '0901',
' ' 'BDC_OKCODE' '=BU'.
CALL TRANSACTION 'CJ20'
USING bdc_tab
* MODE 'A'
MODE 'E'
UPDATE 'S'.
ENDAT.
ENDLOOP.
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Form dynpro_bdc_tab
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0010 text
* -->P_0011 text
* -->P_0012 text
*----------------------------------------------------------------------*
FORM dynpro_bdc_tab USING dynbegin
name
value.
IF dynbegin = 'X'.
CLEAR bdc_tab.
MOVE: dynbegin TO bdc_tab-dynbegin,
name TO bdc_tab-program,
value TO bdc_tab-dynpro.
APPEND bdc_tab.
ELSE.
CLEAR bdc_tab.
MOVE: name TO bdc_tab-fnam,
value TO bdc_tab-fval.
APPEND bdc_tab.
ENDIF.
ENDFORM. " dynpro_bdc_tab