2012 Apr 12 7:01 AM
hi,
I am uploading data using BDC Table Control.. up to 7 records its uploading after that my scroll down '=P+' is not working. can any one help me code for scroll down functionality in BDC table control .
2012 Apr 12 7:21 AM
Can you tell me for which Transaction are u working???
Usually P+ doesnt work.... SO Just follow this:
In that Transaction after inputting 7th record, just select 7th line item and see if there exists a row insert button. If yes, then prepare BDC for this using SHDB transaction in this pattern.
i.e.
Select last line item
Click on Insert Row.
Add 8th Record which will be added in the 7th line only and the existing 7th record will be moved to 8th line.
Again select 7th line item and do repeat the above steps.
This will help u to add more than 7 records.
2012 Apr 12 7:40 AM
2012 Apr 12 7:53 AM
Yes there is a single + button in the bottom 5th from left side.
What u do is...Prepare a BDC using SHDB in the order which i am telling u... i have implemented this a long time ago successfully
Suppose last line item id 7th here. input data here i.e. 7th record... then
select 7th line item
Click on Insert Row. the 7th record will be shifted to 8th line and
Now u can Add 8th Record in the 7th line only
Again select 7th line item and do repeat the above steps.
2012 Apr 12 8:22 AM
hi ,, i pasted my code still its not working
LOOP AT T_HEADER INTO W_HEADER.
REFRESH T_BDCDATA.
erform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'/ECCDE'.
perform bdc_field using 'ACGL_HEAD-BLDAT'
W_HEADER-BLDAT. "'03/22/2012'.
perform bdc_dynpro using 'SAPLACHD' '1000'.
perform bdc_field using 'BDC_CURSOR'
'BKPF-BUKRS'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'BKPF-BUKRS'
W_HEADER-BUKRS. "'3000'.
*perform bdc_transaction using 'FV50L'.
perform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'ACGL_HEAD-BLDAT'
W_HEADER-BLDAT. "'03/22/2012'.
perform bdc_field using 'ACGL_HEAD-WAERS'
W_HEADER-WAERS."'CNY'.
perform bdc_field using 'ACGL_HEAD-BUDAT'
W_HEADER-BUDAT."'03/28/2012'.
perform bdc_field using 'ACGL_HEAD-LDGRP'
W_HEADER-LDGRP."''.
perform bdc_field using 'ACGL_HEAD-XBLNR'
W_HEADER-XBLNR."'Salary of Feb'.
perform bdc_field using 'ACGL_HEAD-BKTXT'
W_HEADER-BKTXT."'Salary for Feb12'.
perform bdc_field using 'ACGL_HEAD-BLART'
W_HEADER-BLART."'ZZ'.
L_N = 1.
LOOP AT T_ITEM INTO W_ITEM WHERE BLDAT = W_HEADER-BLDAT.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-HKONT(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD"'ACGL_ITEM-HKONT(01)'
W_ITEM-HKONT." '50100010'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-SHKZG(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-SHKZG(01)'
W_ITEM-SHKZG."'S'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-WRBTR(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-WRBTR(01)'
W_ITEM-WRBTR."' 200'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-SGTXT(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-SGTXT(01)'
W_ITEM-SGTXT."'2月_基本工资'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-GSBER(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-GSBER(01)'
W_ITEM-GSBER."'3000'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-KOSTL(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-KOSTL(01)'
W_ITEM-KOSTL."'30001'.
perform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-PRCTR(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-PRCTR(02)'
IF L_N = 8. " Change this to greater than and try
L_N = 1.
perform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=P+'.
ENDIF.
ENDLOOP.
perform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'=PBBP'.
CALL TRANSACTION 'FV50L' USING T_BDCDATA OPTIONS FROM opt
* MODE 'A'
MESSAGES INTO T_MSG.
2012 Apr 12 8:42 AM
This is Wrong... I will share a sample with u... analyze it ok....
In this way create urs... this is for transaction FB60... Since i have used default size in call transaction... by default in table control only 4 records can be inserted...
LOOP AT it_item INTO wa_item.
count = sy-tabix.
IF count GT 4. " Start of Changes as on 20/02/2012
count1 = 4.
PERFORM bdc_screen USING 'SAPMF05A' '1100'.
PERFORM bdc_data USING 'BDC_OKCODE' '=0005'.
PERFORM bdc_data USING 'BDC_CURSOR' 'ACGL_ITEM-STATE(04)'.
PERFORM bdc_data USING 'INVFO-ACCNT' wa_header-newko.
PERFORM bdc_data USING 'INVFO-XBLNR' wa_header-xblnr.
PERFORM bdc_data USING 'ACGL_ITEM-MARKSP(04)' 'X'.
*****First convert
CLEAR: it_amount, et_amount.
it_amount-tcur = 'INR'.
it_amount-t_amount = wa_header-wrbtr.
CALL FUNCTION 'BKK_AMOUNT_CONV_TO_INTERN_MAIN'
EXPORTING
i_amount = it_amount
IMPORTING
e_amount = et_amount
EXCEPTIONS
amounts_not_valid = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
****First convert
WRITE et_amount-t_amount TO l_amount1.
PERFORM bdc_data USING 'INVFO-WRBTR' l_amount1.
PERFORM bdc_data USING 'INVFO-BUPLA' wa_header-bupla.
PERFORM bdc_data USING 'INVFO-SECCO' wa_header-secco.
PERFORM bdc_data USING 'INVFO-SGTXT' wa_header-sgtxt.
PERFORM bdc_screen USING 'SAPMF05A' '1100'.
PERFORM bdc_data USING 'BDC_OKCODE' '=0005'.
PERFORM bdc_data USING 'BDC_CURSOR' 'ACGL_ITEM-HKONT(04)'.
* PERFORM bdc_data USING 'RF05A-BUSCS' 'R'.
* PERFORM bdc_data USING 'BDC_SUBSCR' 'SAPLFDCB 0010PAGE'.
PERFORM bdc_data USING 'INVFO-ACCNT' wa_header-newko.
PERFORM bdc_data USING 'INVFO-XBLNR' wa_header-xblnr.
CLEAR: it_amount, et_amount.
it_amount-tcur = 'INR'.
it_amount-t_amount = wa_header-wrbtr.
CALL FUNCTION 'BKK_AMOUNT_CONV_TO_INTERN_MAIN'
EXPORTING
i_amount = it_amount
IMPORTING
e_amount = et_amount
EXCEPTIONS
amounts_not_valid = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
****First convert
WRITE et_amount-t_amount TO l_amount1.
PERFORM bdc_data USING 'INVFO-WRBTR' l_amount1.
PERFORM bdc_data USING 'INVFO-BUPLA' wa_header-bupla.
PERFORM bdc_data USING 'INVFO-SECCO' wa_header-secco.
PERFORM bdc_data USING 'INVFO-SGTXT' wa_header-sgtxt.
CLEAR g_var_str.
CONCATENATE 'ACGL_ITEM-HKONT(' count1 ')' INTO g_var_str.
CONDENSE g_var_str.
PERFORM bdc_data USING g_var_str wa_item-hkont.
CLEAR g_var_str.
CONCATENATE 'ACGL_ITEM-WRBTR(' count1 ')' INTO g_var_str.
CONDENSE g_var_str.
****First convert
CLEAR: it_amount, et_amount.
it_amount-tcur = 'INR'.
it_amount-t_amount = wa_item-wrbtr.
CALL FUNCTION 'BKK_AMOUNT_CONV_TO_INTERN_MAIN'
EXPORTING
i_amount = it_amount
IMPORTING
e_amount = et_amount
EXCEPTIONS
amounts_not_valid = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
****First convert
WRITE et_amount-t_amount TO l_amount1.
PERFORM bdc_data USING g_var_str l_amount1.
CLEAR g_var_str.
CONCATENATE 'ACGL_ITEM-KOSTL(' count1 ')' INTO g_var_str.
CONDENSE g_var_str.
PERFORM bdc_data USING g_var_str wa_item-kostl. " End of Changes as on 20/02/2012
CLEAR g_var_str.
" Start of Changes as on 17/02/2012
* CONCATENATE 'ACGL_ITEM-MWSKZ(' count1 ')' INTO g_var_str.
* CONDENSE g_var_str.
* PERFORM bdc_data USING g_var_str 'M1'.
*
* CLEAR g_var_str.
* CONCATENATE 'ACGL_ITEM-TXJCD(' count1 ')' INTO g_var_str.
* CONDENSE g_var_str.
* PERFORM bdc_data USING g_var_str 'IN00'.
*
* CLEAR g_var_str.
" End of Changes as on 17/02/2012
ELSE.
CLEAR g_var_str.
CONCATENATE 'ACGL_ITEM-HKONT(' count ')' INTO g_var_str.
CONDENSE g_var_str.
PERFORM bdc_data USING g_var_str wa_item-hkont.
CLEAR g_var_str.
CONCATENATE 'ACGL_ITEM-WRBTR(' count ')' INTO g_var_str.
CONDENSE g_var_str.
****First convert
CLEAR: it_amount, et_amount.
it_amount-tcur = 'INR'.
it_amount-t_amount = wa_item-wrbtr.
CALL FUNCTION 'BKK_AMOUNT_CONV_TO_INTERN_MAIN'
EXPORTING
i_amount = it_amount
IMPORTING
e_amount = et_amount
EXCEPTIONS
amounts_not_valid = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
****First convert
WRITE et_amount-t_amount TO l_amount1.
PERFORM bdc_data USING g_var_str l_amount1.
CLEAR g_var_str.
" Start of Changes as on 17/02/2012
* CONCATENATE 'ACGL_ITEM-MWSKZ(' count ')' INTO g_var_str.
* CONDENSE g_var_str.
* PERFORM bdc_data USING g_var_str 'M1'.
*
* CLEAR g_var_str.
* CONCATENATE 'ACGL_ITEM-TXJCD(' count ')' INTO g_var_str.
* CONDENSE g_var_str.
* PERFORM bdc_data USING g_var_str 'IN00'.
*
* CLEAR g_var_str.
" End of Changes as on 17/02/2012
CONCATENATE 'ACGL_ITEM-KOSTL(' count ')' INTO g_var_str.
CONDENSE g_var_str.
PERFORM bdc_data USING g_var_str wa_item-kostl.
ENDIF.
ENDLOOP.
2012 Apr 12 9:39 AM
now after 7 records ,, again its replacing new records on first filled 7 records but not going page down
2012 Apr 12 9:43 AM
Send me ur code again...
I will check it after making updations....
2012 Apr 12 9:51 AM
LOOP AT T_HEADER INTO W_HEADER.
REFRESH T_BDCDATA.
erform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'/ECCDE'.
perform bdc_field using 'ACGL_HEAD-BLDAT'
W_HEADER-BLDAT. "'03/22/2012'.
perform bdc_dynpro using 'SAPLACHD' '1000'.
perform bdc_field using 'BDC_CURSOR'
'BKPF-BUKRS'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'BKPF-BUKRS'
W_HEADER-BUKRS. "'3000'.
*perform bdc_transaction using 'FV50L'.
perform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'ACGL_HEAD-BLDAT'
W_HEADER-BLDAT. "'03/22/2012'.
perform bdc_field using 'ACGL_HEAD-WAERS'
W_HEADER-WAERS."'CNY'.
perform bdc_field using 'ACGL_HEAD-BUDAT'
W_HEADER-BUDAT."'03/28/2012'.
perform bdc_field using 'ACGL_HEAD-LDGRP'
W_HEADER-LDGRP."''.
perform bdc_field using 'ACGL_HEAD-XBLNR'
W_HEADER-XBLNR."'Salary of Feb'.
perform bdc_field using 'ACGL_HEAD-BKTXT'
W_HEADER-BKTXT."'Salary for Feb12'.
perform bdc_field using 'ACGL_HEAD-BLART'
W_HEADER-BLART."'ZZ'.
L_N = 1.
LOOP AT T_ITEM INTO W_ITEM WHERE BLDAT = W_HEADER-BLDAT.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-HKONT(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD"'ACGL_ITEM-HKONT(01)'
W_ITEM-HKONT." '50100010'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-SHKZG(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-SHKZG(01)'
W_ITEM-SHKZG."'S'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-WRBTR(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-WRBTR(01)'
W_ITEM-WRBTR."' 200'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-SGTXT(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-SGTXT(01)'
W_ITEM-SGTXT."'2月_基本工资'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-GSBER(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-GSBER(01)'
W_ITEM-GSBER."'3000'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-KOSTL(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-KOSTL(01)'
W_ITEM-KOSTL."'30001'.
perform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-PRCTR(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-PRCTR(02)'
W_ITEM-PRCTR.
L_N = L_N + 1.
IF L_N = 8. " Change this to greater than and try
L_N = 1.
perform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=P+'.
ENDIF.
ENDLOOP.
perform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'=PBBP'.
CALL TRANSACTION 'FV50L' USING T_BDCDATA OPTIONS FROM opt
* MODE 'A'
MESSAGES INTO T_MSG.
2012 Apr 12 9:55 AM
*&---------------------------------------------------------------------*
*& Structure Declaration
*&---------------------------------------------------------------------*
* Structure declaration for Header
TYPES: BEGIN OF TY_HEADER,
* BUKRS type BKPF-BUKRS, "Company Code
BLDAT type CHAR10,"ACGL_HEAD-BLDAT, "Document Date 8
WAERS type ACGL_HEAD-WAERS, "Currency 5
BUDAT type CHAR10,"ACGL_HEAD-BUDAT, "Posting Date 8
LDGRP type ACGL_HEAD-LDGRP, "Ledger Grp 4
XBLNR type ACGL_HEAD-XBLNR, "Reference 16
BKTXT type ACGL_HEAD-BKTXT, " Doc.Header Text 25
BLART type ACGL_HEAD-BLART, "Document Type 2
BUKRS type BKPF-BUKRS, "Company Code4
END OF TY_HEADER,
* Structure Declaration for Item
BEGIN OF TY_ITEM,
BLDAT type CHAR10,"ACGL_HEAD-BLDAT,
HKONT type ACGL_ITEM-HKONT, "G/L account 10
SHKZG type ACGL_ITEM-SHKZG, "D/C 1
WRBTR type CHAR20,"ACGL_ITEM-WRBTR, "Amount in document currency 13
SGTXT type ACGL_ITEM-SGTXT, "Text 50
GSBER type ACGL_ITEM-GSBER, "Business area 4
KOSTL type ACGL_ITEM-KOSTL, "Cost center 10
PRCTR type ACGL_ITEM-PRCTR, "Profit center 10
END OF TY_ITEM,
* Structure Delcatation for source
BEGIN OF TY_UPLOAD,
F1 TYPE CHAR10,"4,
F2 TYPE CHAR10,
F3 TYPE CHAR10,"5,
F4 TYPE CHAR13,
F5 TYPE CHAR50,
F6 TYPE CHAR25,"16
F7 TYPE CHAR10,"25,
F8 TYPE CHAR10,
END OF TY_UPLOAD.
*&---------------------------------------------------------------------*
*& Source internal table Declaration
*&---------------------------------------------------------------------*
* Internal table declaration for header
DATA:T_HEADER TYPE STANDARD TABLE OF TY_HEADER,
* Internal table declaration for item
T_ITEM TYPE STANDARD TABLE OF TY_ITEM,
* Internal table declaration for source
T_UPLOAD TYPE STANDARD TABLE OF TY_UPLOAD,
t_error type standard table of ty_upload,
* Internal table declaration for target
T_BDCDATA TYPE STANDARD TABLE OF BDCDATA,
* Internal table declartion for message
T_MSG TYPE STANDARD TABLE OF BDCMSGCOLL,
*&---------------------------------------------------------------------*
*& Work area Declaration
*&---------------------------------------------------------------------*
* Work area declaration for header
W_HEADER TYPE TY_HEADER,
* Work area declaration for item
W_ITEM TYPE TY_ITEM,
* Work area declaration for source
W_UPLOAD TYPE TY_UPLOAD,
W_UPLOAD1 TYPE TY_UPLOAD,
* Work area declaration for target
W_BDCDATA TYPE BDCDATA,
* Work area declaration for message
W_MSG TYPE BDCMSGCOLL.
field-symbols : <fs>.
DATA : l_intern type standard table of alsmex_tabline.
data : l_index type i.
data: wa_intern LIKE alsmex_tabline .
DATA: l_date type sy-datum,
l_year(4) type c,
l_month(2) type c ,
l_day(2) type c.
DATA opt TYPE ctu_params.
opt-dismode = 'A'.
opt-defsize = 'X'.
opt-updmode = 'A'.
opt-nobinpt = 'X'.
opt-RACOMMIT = 'X' .
opt-NOBIEND = 'X' .
*&---------------------------------------------------------------------*
*& Selection screen Declaration
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
*PARAMETERS:P_FLNAME TYPE FILENAME.
PARAMETERS:P_FLNAME LIKE rlgrap-filename.
SELECTION-SCREEN END OF BLOCK B1.
************************************************************************
*At-selection-screen event
************************************************************************
*To provide Input help for file name
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FLNAME.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = SYST-CPROG
dynpro_number = SYST-DYNNR
IMPORTING
file_name = P_FLNAME.
*&---------------------------------------------------------------------*
*& Initialization Event Declaration
*&---------------------------------------------------------------------*
INITIALIZATION.
* Clear work areas
CLEAR:W_HEADER,
W_ITEM,
W_UPLOAD,
W_BDCDATA,
W_MSG.
* Refresh the tables
REFRESH:T_HEADER,
T_ITEM,
T_UPLOAD,
T_BDCDATA,
T_MSG.
*&---------------------------------------------------------------------*
*& Start of selection Declaration
*&---------------------------------------------------------------------*
START-OF-SELECTION.
* Upload the data
PERFORM SUB_UPLOAD_DATA.
* Pop bdcdata
PERFORM SUB_POP_BDCDATA.
*&---------------------------------------------------------------------*
*& Form SUB_UPLOAD_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM SUB_UPLOAD_DATA .
data : L_FLNAME TYPE rlgrap-filename.
L_FLNAME = P_FLNAME.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = L_FLNAME
I_BEGIN_COL = 1 "startcol
I_BEGIN_ROW = 1 "startrow
I_END_COL = 5000 "endcol
I_END_ROW = 1000000 "endrow
TABLES
INTERN = l_intern
* EXCEPTIONS
* INCONSISTENT_PARAMETERS = 1
* UPLOAD_OLE = 2
* OTHERS = 3
.
IF SY-SUBRC <> 0.
* message 'File should be in Excel' type 'E'.
* leave list-processing.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT l_intern into WA_intern.
MOVE WA_INTERN-COL TO L_INDEX.
ASSIGN COMPONENT L_INDEX OF STRUCTURE W_UPLOAD TO <FS>.
MOVE WA_INTERN-VALUE TO <FS>.
AT END OF ROW.
APPEND W_UPLOAD TO T_UPLOAD.
CLEAR W_UPLOAD.
ENDAT.
ENDLOOP.
LOOP AT T_UPLOAD INTO W_UPLOAD1.
***W_UPLOAD = W_UPLOAD1.
*** move W_UPLOAD-F1+0(2) to l_date.
*** move W_UPLOAD-F1+3(2) to l_month.
*** move W_UPLOAD-F1+6(4) to l_year.
*** concatenate l_month'/'l_date'/' l_year into W_UPLOAD-F1.
***
*** move W_UPLOAD-F3+0(2) to l_date.
*** move W_UPLOAD-F3+3(2) to l_month.
*** move W_UPLOAD-F3+6(4) to l_year.
*** concatenate l_month'/'l_date'/' l_year into W_UPLOAD-F3.
W_UPLOAD = W_UPLOAD1.
find '.' in W_UPLOAD-F1.
find '.' in W_UPLOAD-F3.
if sy-subrc = 0.
replace '.' with '/' into W_UPLOAD-F1.
replace '.' with '/' into W_UPLOAD-F3.
* CONDENSE W_UPLOAD-F1 NO-GAPS.
* CONDENSE W_UPLOAD-F3 NO-GAPS.
if sy-subrc = 0.
replace '.' with '/' into W_UPLOAD-F1.
replace '.' with '/' into W_UPLOAD-F3.
* CONDENSE W_UPLOAD-F1 NO-GAPS.
* CONDENSE W_UPLOAD-F3 NO-GAPS.
endif.
endif.
* Moving header data
AT NEW F1.
* W_HEADER-BUKRS = W_UPLOAD-F1.
W_HEADER-BLDAT = W_UPLOAD-F1.
W_HEADER-WAERS = W_UPLOAD-F2.
W_HEADER-BUDAT = W_UPLOAD-F3.
W_HEADER-LDGRP = W_UPLOAD-F4.
W_HEADER-XBLNR = W_UPLOAD-F5.
W_HEADER-BKTXT = W_UPLOAD-F6.
W_HEADER-BLART = W_UPLOAD-F7.
W_HEADER-BUKRS = W_UPLOAD-F8.
* W_HEADER-FDGRV = W_UPLOAD-F9.
* W_HEADER-WAERS = W_UPLOAD-F10.
APPEND W_HEADER TO T_HEADER.
CLEAR W_HEADER.
CONTINUE.
ENDAT.
* Moving the item data
* move W_UPLOAD-F1+0(2) to l_date.
* move W_UPLOAD-F1+3(2) to l_month.
* move W_UPLOAD-F1+6(4) to l_year.
* concatenate l_month'/'l_date'/' l_year into W_UPLOAD-F1.
find '.' in W_UPLOAD-F1.
if sy-subrc = 0.
replace '.' with '/' into W_UPLOAD-F1.
CONDENSE W_UPLOAD-F1 NO-GAPS.
if sy-subrc = 0.
replace '.' with '/' into W_UPLOAD-F1.
CONDENSE W_UPLOAD-F1 NO-GAPS.
endif.
endif.
* W_ITEM-BUKRS = W_UPLOAD-F1.
W_ITEM-BLDAT = W_UPLOAD-F1.
W_ITEM-HKONT = W_UPLOAD-F2. "G/L account
W_ITEM-SHKZG = W_UPLOAD-F3. "D/C
W_ITEM-WRBTR = W_UPLOAD-F4. "Amount in document currency
W_ITEM-SGTXT = W_UPLOAD-F5. "Text
W_ITEM-GSBER = W_UPLOAD-F6. "Business area
W_ITEM-KOSTL = W_UPLOAD-F7. "Cost center
W_ITEM-PRCTR = W_UPLOAD-F8.
APPEND W_ITEM TO T_ITEM.
CLEAR: W_ITEM, l_month, l_date, l_year.
ENDLOOP.
ENDFORM. " SUB_UPLOAD_DATA
*&---------------------------------------------------------------------*
*& Form SUB_POP_BDCDATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM SUB_POP_BDCDATA .
DATA:L_FIELD TYPE CHAR20," CHAR132."20,
L_N TYPE CHAR2.
* data: v_flines TYPE i,
* v_tabix TYPE sytabix,
* l_tabix TYPE sytabix.
* data :tc_lines type char4.
DATA : L_MSG TYPE STRING.
** data: LV_BLDAT TYPE SY-DATUM.
*DESCRIBE TABLE T_HEADER LINES v_flines.
LOOP AT T_HEADER INTO W_HEADER.
** LV_BLDAT = W_HEADER-BLDAT.
** CLEAR W_HEADER-BLDAT.
** WRITE LV_BLDAT TO W_HEADER-BLDAT.
REFRESH T_BDCDATA.
perform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'/ECCDE'.
perform bdc_field using 'ACGL_HEAD-BLDAT'
W_HEADER-BLDAT. "'03/22/2012'.
perform bdc_dynpro using 'SAPLACHD' '1000'.
perform bdc_field using 'BDC_CURSOR'
'BKPF-BUKRS'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'BKPF-BUKRS'
W_HEADER-BUKRS. "'3000'.
*perform bdc_transaction using 'FV50L'.
perform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'ACGL_HEAD-BLDAT'
W_HEADER-BLDAT. "'03/22/2012'.
perform bdc_field using 'ACGL_HEAD-WAERS'
W_HEADER-WAERS."'CNY'.
perform bdc_field using 'ACGL_HEAD-BUDAT'
W_HEADER-BUDAT."'03/28/2012'.
perform bdc_field using 'ACGL_HEAD-LDGRP'
W_HEADER-LDGRP."''.
perform bdc_field using 'ACGL_HEAD-XBLNR'
W_HEADER-XBLNR."'Salary of Feb'.
perform bdc_field using 'ACGL_HEAD-BKTXT'
W_HEADER-BKTXT."'Salary for Feb12'.
perform bdc_field using 'ACGL_HEAD-BLART'
W_HEADER-BLART."'ZZ'.
L_N = 1.
LOOP AT T_ITEM INTO W_ITEM WHERE BLDAT = W_HEADER-BLDAT.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-HKONT(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD"'ACGL_ITEM-HKONT(01)'
W_ITEM-HKONT." '50100010'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-SHKZG(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-SHKZG(01)'
W_ITEM-SHKZG."'S'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-WRBTR(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-WRBTR(01)'
W_ITEM-WRBTR."' 200'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-SGTXT(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-SGTXT(01)'
W_ITEM-SGTXT."'2月_基本工资'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-GSBER(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-GSBER(01)'
W_ITEM-GSBER."'3000'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-KOSTL(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-KOSTL(01)'
W_ITEM-KOSTL."'30001'.
perform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-PRCTR(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-PRCTR(02)'
W_ITEM-PRCTR."'p30005'.
*perform bdc_dynpro using 'SAPMF05A' '1001'.
*perform bdc_field using 'BDC_OKCODE'
* '/00'.
*perform bdc_field using 'BDC_CURSOR'
* 'ACGL_ITEM-PRCTR(02)'.
*perform bdc_field using 'ACGL_ITEM-HKONT(02)'
* '22120001'.
*perform bdc_field using 'ACGL_ITEM-SHKZG(02)'
* 'H'.
*perform bdc_field using 'ACGL_ITEM-WRBTR(02)'
* ' 200'.
*perform bdc_field using 'ACGL_ITEM-SGTXT(02)'
* '2月_基本工资'.
*perform bdc_field using 'ACGL_ITEM-GSBER(02)'
* '3000'.
*****************CLEAR L_FIELD.
*****************CONCATENATE 'ACGL_ITEM-PRCTR(0' L_N ')' INTO L_FIELD.
*****************perform bdc_field using L_FIELD "'ACGL_ITEM-PRCTR(02)'
***************** W_ITEM-PRCTR."'p30005'.
***PERFORM BDC_FIELD using 'BDC_OKCODE' " added newly
*** '=P+'. " added newly
* PERFORM bdc_field USING 'BDC_OKCODE'
* '=P+'.
L_N = L_N + 1.
* PERFORM bdc_field USING 'BDC_OKCODE'
***** '=P+'.
****************
*Loop at it_fill.
*L_N = L_N + 1.
IF L_N = 8. " Change this to greater than and try
L_N = 1.
perform bdc_dynpro using 'SAPMF05A' '1001'.
* perform bdc_field using 'BDC_OKCODE'
* '/00'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=P+'.
*CLEAR L_N.
*L_N = L_N + 1.
ENDIF.
*endloop.
* if L_N > 7.
* perform bdc_dynpro using 'SAPMF05A' '1001'.
* perform bdc_field using 'BDC_OKCODE'
* '=PP+N'.
*
* L_N = 8.
*** exit.
*** L_N = 1.
*** perform bdc_field using 'BDC_OKCODE'
*** '=P+'.
**
*** exit.
* endif.
*************
ENDLOOP.
perform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'=PBBP'.
*perform bdc_transaction using 'FV50L'.
REFRESH T_MSG.
CALL TRANSACTION 'FV50L' USING T_BDCDATA OPTIONS FROM opt
* MODE 'A'
MESSAGES INTO T_MSG.
IF SY-SUBRC <> 0.
APPEND W_UPLOAD TO T_ERROR.
ENDIF.
LOOP AT T_MSG INTO W_MSG.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = W_MSG-MSGID
LANG = SY-LANGU
NO = W_MSG-MSGNR
V1 = W_MSG-MSGV1
V2 = W_MSG-MSGV2
V3 = W_MSG-MSGV3
V4 = W_MSG-MSGV4
IMPORTING
MSG = L_MSG
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2
.
IF SY-SUBRC = 0.
WRITE : /2 W_UPLOAD-F1, 18 W_MSG-MSGTYP, 30 L_MSG.
ENDIF.
ENDLOOP.
ENDLOOP.
ENDFORM. " SUB_POP_BDCDATA
*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR W_BDCDATA.
W_BDCDATA-PROGRAM = PROGRAM.
W_BDCDATA-DYNPRO = DYNPRO.
W_BDCDATA-DYNBEGIN = 'X'.
APPEND W_BDCDATA TO T_BDCDATA.
ENDFORM. "BDC_DYNPRO
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
CLEAR W_BDCDATA.
W_BDCDATA-FNAM = FNAM.
W_BDCDATA-FVAL = FVAL.
APPEND W_BDCDATA TO T_BDCDATA.
ENDFORM. "BDC_FIELD
2012 Apr 12 10:11 AM
Few Changes...
1. declare l_n = 0 instead of l_n = 1.
2. as soon as the loop starts,
i.e.LOOP AT t_item INTO w_item WHERE bldat = w_header-bldat.
CLEAR l_field.
write here l_n = l_n + 1.
3. Now write an if statement i.e. if l_n < 8
write....
CONCATENATE 'ACGL_ITEM-HKONT(0' l_n ')' INTO l_field.
PERFORM bdc_field USING l_field"'ACGL_ITEM-HKONT(01)'
w_item-hkont." '50100010'.
CLEAR l_field.
CONCATENATE 'ACGL_ITEM-SHKZG(0' l_n ')' INTO l_field.
PERFORM bdc_field USING l_field "'ACGL_ITEM-SHKZG(01)'
w_item-shkzg."'S'.
CLEAR l_field.
CONCATENATE 'ACGL_ITEM-WRBTR(0' l_n ')' INTO l_field.
PERFORM bdc_field USING l_field "'ACGL_ITEM-WRBTR(01)'
w_item-wrbtr."' 200'. and SO on
Else.
l_n = 7
Dont write the code u have written..
u shud write the code here to select the 7th line item
click on insert row (and dont do scroll, there is + button in the bottom)
Similar to this one.,...
PERFORM bdc_data USING 'BDC_OKCODE' '=0005'.
PERFORM bdc_data USING 'BDC_CURSOR' 'ACGL_ITEM-STATE(07)'.
PERFORM bdc_data USING 'INVFO-ACCNT' wa_header-newko.
PERFORM bdc_data USING 'INVFO-XBLNR' wa_header-xblnr.
PERFORM bdc_data USING 'ACGL_ITEM-MARKSP(04)' 'X'. "This selects the 7th line item
PERFORM bdc_screen USING 'SAPMF05A' '1100'.
PERFORM bdc_data USING 'BDC_OKCODE' '=0005'. "This Adds/inserts row
PERFORM bdc_data USING 'BDC_CURSOR' 'ACGL_ITEM-HKONT(04)'.
* PERFORM bdc_data USING 'RF05A-BUSCS' 'R'.
* PERFORM bdc_data USING 'BDC_SUBSCR' 'SAPLFDCB 0010PAGE'.
PERFORM bdc_data USING 'INVFO-ACCNT' wa_header-newko.
PERFORM bdc_data USING 'INVFO-XBLNR' wa_header-xblnr.
2012 Apr 12 9:38 AM
Hi Mahesh,
I have observed that after entering 7th record & pressing "enter" the first record goes up behind & the 7th record comes to 6th poistion & 7th position becomes ready for input for subsequent records.
So till 7th record you may increment the line item counter & then keep the counter after 7 constant to "07" for next records whatever maybe the no. of records.
Try & let me know.
Also find the Attached bdc recording file done for the same.
Sharath
2012 Apr 12 10:14 AM
In your code, edit the following:
IF L_N = 8. " Change this to greater than and try
L_N = 1. L_N = 2.
perform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=P+'.
perform bdc_dynpro using 'SAPMF05A' '1001'.
ENDIF.
2012 Apr 12 10:33 AM
hi
i did as you said but its not working.. when i changed to 2 then second record of first updated records getting replaced but scoller is not moving ...
2012 Apr 12 11:13 AM
Please try the code below. Not sure why you're comparing it to 8 (in my system I can input 10 entries before it scrolls down)
IF L_N > 8. " Change this to greater than and try
L_N = 8.
perform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
ENDIF.
2012 Apr 12 11:41 AM
2012 Apr 12 11:58 AM
Send me the new code again i mean what did u modify.... or execute the BDC in E mode???
2012 Apr 12 12:04 PM
*&---------------------------------------------------------------------*
*& Structure Declaration
*&---------------------------------------------------------------------*
* Structure declaration for Header
TYPES: BEGIN OF TY_HEADER,
* BUKRS type BKPF-BUKRS, "Company Code
BLDAT type CHAR10,"ACGL_HEAD-BLDAT, "Document Date 8
WAERS type ACGL_HEAD-WAERS, "Currency 5
BUDAT type CHAR10,"ACGL_HEAD-BUDAT, "Posting Date 8
LDGRP type ACGL_HEAD-LDGRP, "Ledger Grp 4
XBLNR type ACGL_HEAD-XBLNR, "Reference 16
BKTXT type ACGL_HEAD-BKTXT, " Doc.Header Text 25
BLART type ACGL_HEAD-BLART, "Document Type 2
BUKRS type BKPF-BUKRS, "Company Code4
END OF TY_HEADER,
* Structure Declaration for Item
BEGIN OF TY_ITEM,
BLDAT type CHAR10,"ACGL_HEAD-BLDAT,
HKONT type ACGL_ITEM-HKONT, "G/L account 10
SHKZG type ACGL_ITEM-SHKZG, "D/C 1
WRBTR type CHAR20,"ACGL_ITEM-WRBTR, "Amount in document currency 13
SGTXT type ACGL_ITEM-SGTXT, "Text 50
GSBER type ACGL_ITEM-GSBER, "Business area 4
KOSTL type ACGL_ITEM-KOSTL, "Cost center 10
PRCTR type ACGL_ITEM-PRCTR, "Profit center 10
END OF TY_ITEM,
* Structure Delcatation for source
BEGIN OF TY_UPLOAD,
F1 TYPE CHAR10,"4,
F2 TYPE CHAR10,
F3 TYPE CHAR10,"5,
F4 TYPE CHAR13,
F5 TYPE CHAR50,
F6 TYPE CHAR25,"16
F7 TYPE CHAR10,"25,
F8 TYPE CHAR10,
END OF TY_UPLOAD.
*&---------------------------------------------------------------------*
*& Source internal table Declaration
*&---------------------------------------------------------------------*
* Internal table declaration for header
DATA:T_HEADER TYPE STANDARD TABLE OF TY_HEADER,
* Internal table declaration for item
T_ITEM TYPE STANDARD TABLE OF TY_ITEM,
* Internal table declaration for source
T_UPLOAD TYPE STANDARD TABLE OF TY_UPLOAD,
t_error type standard table of ty_upload,
* Internal table declaration for target
T_BDCDATA TYPE STANDARD TABLE OF BDCDATA,
* Internal table declartion for message
T_MSG TYPE STANDARD TABLE OF BDCMSGCOLL,
*&---------------------------------------------------------------------*
*& Work area Declaration
*&---------------------------------------------------------------------*
* Work area declaration for header
W_HEADER TYPE TY_HEADER,
* Work area declaration for item
W_ITEM TYPE TY_ITEM,
* Work area declaration for source
W_UPLOAD TYPE TY_UPLOAD,
W_UPLOAD1 TYPE TY_UPLOAD,
* Work area declaration for target
W_BDCDATA TYPE BDCDATA,
* Work area declaration for message
W_MSG TYPE BDCMSGCOLL.
field-symbols : <fs>.
DATA : l_intern type standard table of alsmex_tabline.
data : l_index type i.
data: wa_intern LIKE alsmex_tabline .
DATA: l_date type sy-datum,
l_year(4) type c,
l_month(2) type c ,
l_day(2) type c.
DATA opt TYPE ctu_params.
opt-dismode = 'A'.
opt-defsize = 'X'.
opt-updmode = 'A'.
opt-nobinpt = 'X'.
opt-RACOMMIT = 'X' .
opt-NOBIEND = 'X' .
*&---------------------------------------------------------------------*
*& Selection screen Declaration
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
*PARAMETERS:P_FLNAME TYPE FILENAME.
PARAMETERS:P_FLNAME LIKE rlgrap-filename.
SELECTION-SCREEN END OF BLOCK B1.
************************************************************************
*At-selection-screen event
************************************************************************
*To provide Input help for file name
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FLNAME.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = SYST-CPROG
dynpro_number = SYST-DYNNR
IMPORTING
file_name = P_FLNAME.
*&---------------------------------------------------------------------*
*& Initialization Event Declaration
*&---------------------------------------------------------------------*
INITIALIZATION.
* Clear work areas
CLEAR:W_HEADER,
W_ITEM,
W_UPLOAD,
W_BDCDATA,
W_MSG.
* Refresh the tables
REFRESH:T_HEADER,
T_ITEM,
T_UPLOAD,
T_BDCDATA,
T_MSG.
*&---------------------------------------------------------------------*
*& Start of selection Declaration
*&---------------------------------------------------------------------*
START-OF-SELECTION.
* Upload the data
PERFORM SUB_UPLOAD_DATA.
* Pop bdcdata
PERFORM SUB_POP_BDCDATA.
*&---------------------------------------------------------------------*
*& Form SUB_UPLOAD_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM SUB_UPLOAD_DATA .
data : L_FLNAME TYPE rlgrap-filename.
L_FLNAME = P_FLNAME.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = L_FLNAME
I_BEGIN_COL = 1 "startcol
I_BEGIN_ROW = 1 "startrow
I_END_COL = 5000 "endcol
I_END_ROW = 1000000 "endrow
TABLES
INTERN = l_intern
* EXCEPTIONS
* INCONSISTENT_PARAMETERS = 1
* UPLOAD_OLE = 2
* OTHERS = 3
.
IF SY-SUBRC <> 0.
* message 'File should be in Excel' type 'E'.
* leave list-processing.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT l_intern into WA_intern.
MOVE WA_INTERN-COL TO L_INDEX.
ASSIGN COMPONENT L_INDEX OF STRUCTURE W_UPLOAD TO <FS>.
MOVE WA_INTERN-VALUE TO <FS>.
AT END OF ROW.
APPEND W_UPLOAD TO T_UPLOAD.
CLEAR W_UPLOAD.
ENDAT.
ENDLOOP.
LOOP AT T_UPLOAD INTO W_UPLOAD1.
***W_UPLOAD = W_UPLOAD1.
*** move W_UPLOAD-F1+0(2) to l_date.
*** move W_UPLOAD-F1+3(2) to l_month.
*** move W_UPLOAD-F1+6(4) to l_year.
*** concatenate l_month'/'l_date'/' l_year into W_UPLOAD-F1.
***
*** move W_UPLOAD-F3+0(2) to l_date.
*** move W_UPLOAD-F3+3(2) to l_month.
*** move W_UPLOAD-F3+6(4) to l_year.
*** concatenate l_month'/'l_date'/' l_year into W_UPLOAD-F3.
W_UPLOAD = W_UPLOAD1.
find '.' in W_UPLOAD-F1.
find '.' in W_UPLOAD-F3.
if sy-subrc = 0.
replace '.' with '/' into W_UPLOAD-F1.
replace '.' with '/' into W_UPLOAD-F3.
* CONDENSE W_UPLOAD-F1 NO-GAPS.
* CONDENSE W_UPLOAD-F3 NO-GAPS.
if sy-subrc = 0.
replace '.' with '/' into W_UPLOAD-F1.
replace '.' with '/' into W_UPLOAD-F3.
* CONDENSE W_UPLOAD-F1 NO-GAPS.
* CONDENSE W_UPLOAD-F3 NO-GAPS.
endif.
endif.
* Moving header data
AT NEW F1.
* W_HEADER-BUKRS = W_UPLOAD-F1.
W_HEADER-BLDAT = W_UPLOAD-F1.
W_HEADER-WAERS = W_UPLOAD-F2.
W_HEADER-BUDAT = W_UPLOAD-F3.
W_HEADER-LDGRP = W_UPLOAD-F4.
W_HEADER-XBLNR = W_UPLOAD-F5.
W_HEADER-BKTXT = W_UPLOAD-F6.
W_HEADER-BLART = W_UPLOAD-F7.
W_HEADER-BUKRS = W_UPLOAD-F8.
* W_HEADER-FDGRV = W_UPLOAD-F9.
* W_HEADER-WAERS = W_UPLOAD-F10.
APPEND W_HEADER TO T_HEADER.
CLEAR W_HEADER.
CONTINUE.
ENDAT.
* Moving the item data
* move W_UPLOAD-F1+0(2) to l_date.
* move W_UPLOAD-F1+3(2) to l_month.
* move W_UPLOAD-F1+6(4) to l_year.
* concatenate l_month'/'l_date'/' l_year into W_UPLOAD-F1.
find '.' in W_UPLOAD-F1.
if sy-subrc = 0.
replace '.' with '/' into W_UPLOAD-F1.
CONDENSE W_UPLOAD-F1 NO-GAPS.
if sy-subrc = 0.
replace '.' with '/' into W_UPLOAD-F1.
CONDENSE W_UPLOAD-F1 NO-GAPS.
endif.
endif.
* W_ITEM-BUKRS = W_UPLOAD-F1.
W_ITEM-BLDAT = W_UPLOAD-F1.
W_ITEM-HKONT = W_UPLOAD-F2. "G/L account
W_ITEM-SHKZG = W_UPLOAD-F3. "D/C
W_ITEM-WRBTR = W_UPLOAD-F4. "Amount in document currency
W_ITEM-SGTXT = W_UPLOAD-F5. "Text
W_ITEM-GSBER = W_UPLOAD-F6. "Business area
W_ITEM-KOSTL = W_UPLOAD-F7. "Cost center
W_ITEM-PRCTR = W_UPLOAD-F8.
APPEND W_ITEM TO T_ITEM.
CLEAR: W_ITEM, l_month, l_date, l_year.
ENDLOOP.
ENDFORM. " SUB_UPLOAD_DATA
*&---------------------------------------------------------------------*
*& Form SUB_POP_BDCDATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM SUB_POP_BDCDATA .
DATA:L_FIELD TYPE CHAR20," CHAR132."20,
L_N TYPE CHAR2.
* data: v_flines TYPE i,
* v_tabix TYPE sytabix,
* l_tabix TYPE sytabix.
* data :tc_lines type char4.
DATA : L_MSG TYPE STRING.
** data: LV_BLDAT TYPE SY-DATUM.
*DESCRIBE TABLE T_HEADER LINES v_flines.
LOOP AT T_HEADER INTO W_HEADER.
** LV_BLDAT = W_HEADER-BLDAT.
** CLEAR W_HEADER-BLDAT.
** WRITE LV_BLDAT TO W_HEADER-BLDAT.
REFRESH T_BDCDATA.
perform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'/ECCDE'.
perform bdc_field using 'ACGL_HEAD-BLDAT'
W_HEADER-BLDAT. "'03/22/2012'.
perform bdc_dynpro using 'SAPLACHD' '1000'.
perform bdc_field using 'BDC_CURSOR'
'BKPF-BUKRS'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'BKPF-BUKRS'
W_HEADER-BUKRS. "'3000'.
*perform bdc_transaction using 'FV50L'.
perform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'ACGL_HEAD-BLDAT'
W_HEADER-BLDAT. "'03/22/2012'.
perform bdc_field using 'ACGL_HEAD-WAERS'
W_HEADER-WAERS."'CNY'.
perform bdc_field using 'ACGL_HEAD-BUDAT'
W_HEADER-BUDAT."'03/28/2012'.
perform bdc_field using 'ACGL_HEAD-LDGRP'
W_HEADER-LDGRP."''.
perform bdc_field using 'ACGL_HEAD-XBLNR'
W_HEADER-XBLNR."'Salary of Feb'.
perform bdc_field using 'ACGL_HEAD-BKTXT'
W_HEADER-BKTXT."'Salary for Feb12'.
perform bdc_field using 'ACGL_HEAD-BLART'
W_HEADER-BLART."'ZZ'.
L_N = 1.
LOOP AT T_ITEM INTO W_ITEM WHERE BLDAT = W_HEADER-BLDAT.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-HKONT(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD"'ACGL_ITEM-HKONT(01)'
W_ITEM-HKONT." '50100010'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-SHKZG(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-SHKZG(01)'
W_ITEM-SHKZG."'S'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-WRBTR(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-WRBTR(01)'
W_ITEM-WRBTR."' 200'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-SGTXT(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-SGTXT(01)'
W_ITEM-SGTXT."'2月_基本工资'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-GSBER(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-GSBER(01)'
W_ITEM-GSBER."'3000'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-KOSTL(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-KOSTL(01)'
W_ITEM-KOSTL."'30001'.
perform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-PRCTR(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-PRCTR(02)'
W_ITEM-PRCTR."'p30005'.
*perform bdc_dynpro using 'SAPMF05A' '1001'.
*perform bdc_field using 'BDC_OKCODE'
* '/00'.
*perform bdc_field using 'BDC_CURSOR'
* 'ACGL_ITEM-PRCTR(02)'.
*perform bdc_field using 'ACGL_ITEM-HKONT(02)'
* '22120001'.
*perform bdc_field using 'ACGL_ITEM-SHKZG(02)'
* 'H'.
*perform bdc_field using 'ACGL_ITEM-WRBTR(02)'
* ' 200'.
*perform bdc_field using 'ACGL_ITEM-SGTXT(02)'
* '2月_基本工资'.
*perform bdc_field using 'ACGL_ITEM-GSBER(02)'
* '3000'.
*****************CLEAR L_FIELD.
*****************CONCATENATE 'ACGL_ITEM-PRCTR(0' L_N ')' INTO L_FIELD.
*****************perform bdc_field using L_FIELD "'ACGL_ITEM-PRCTR(02)'
***************** W_ITEM-PRCTR."'p30005'.
***PERFORM BDC_FIELD using 'BDC_OKCODE' " added newly
*** '=P+'. " added newly
* PERFORM bdc_field USING 'BDC_OKCODE'
* '=P+'.
L_N = L_N + 1.
* PERFORM bdc_field USING 'BDC_OKCODE'
***** '=P+'.
****************
*Loop at it_fill.
*L_N = L_N + 1.
IF L_N = 8. " Change this to greater than and try
L_N = 1.
perform bdc_dynpro using 'SAPMF05A' '1001'.
* perform bdc_field using 'BDC_OKCODE'
* '/00'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=P+'.
*CLEAR L_N.
*L_N = L_N + 1.
ENDIF.
*endloop.
* if L_N > 7.
* perform bdc_dynpro using 'SAPMF05A' '1001'.
* perform bdc_field using 'BDC_OKCODE'
* '=PP+N'.
*
* L_N = 8.
*** exit.
*** L_N = 1.
*** perform bdc_field using 'BDC_OKCODE'
*** '=P+'.
**
*** exit.
* endif.
*************
ENDLOOP.
perform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'=PBBP'.
*perform bdc_transaction using 'FV50L'.
REFRESH T_MSG.
CALL TRANSACTION 'FV50L' USING T_BDCDATA OPTIONS FROM opt
* MODE 'A'
MESSAGES INTO T_MSG.
IF SY-SUBRC <> 0.
APPEND W_UPLOAD TO T_ERROR.
ENDIF.
LOOP AT T_MSG INTO W_MSG.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = W_MSG-MSGID
LANG = SY-LANGU
NO = W_MSG-MSGNR
V1 = W_MSG-MSGV1
V2 = W_MSG-MSGV2
V3 = W_MSG-MSGV3
V4 = W_MSG-MSGV4
IMPORTING
MSG = L_MSG
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2
.
IF SY-SUBRC = 0.
WRITE : /2 W_UPLOAD-F1, 18 W_MSG-MSGTYP, 30 L_MSG.
ENDIF.
ENDLOOP.
ENDLOOP.
ENDFORM. " SUB_POP_BDCDATA
*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR W_BDCDATA.
W_BDCDATA-PROGRAM = PROGRAM.
W_BDCDATA-DYNPRO = DYNPRO.
W_BDCDATA-DYNBEGIN = 'X'.
APPEND W_BDCDATA TO T_BDCDATA.
ENDFORM. "BDC_DYNPRO
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
CLEAR W_BDCDATA.
W_BDCDATA-FNAM = FNAM.
W_BDCDATA-FVAL = FVAL.
APPEND W_BDCDATA TO T_BDCDATA.
ENDFORM. "BDC_FIELD
2012 Apr 12 12:04 PM
*&---------------------------------------------------------------------*
*& Structure Declaration
*&---------------------------------------------------------------------*
* Structure declaration for Header
TYPES: BEGIN OF TY_HEADER,
* BUKRS type BKPF-BUKRS, "Company Code
BLDAT type CHAR10,"ACGL_HEAD-BLDAT, "Document Date 8
WAERS type ACGL_HEAD-WAERS, "Currency 5
BUDAT type CHAR10,"ACGL_HEAD-BUDAT, "Posting Date 8
LDGRP type ACGL_HEAD-LDGRP, "Ledger Grp 4
XBLNR type ACGL_HEAD-XBLNR, "Reference 16
BKTXT type ACGL_HEAD-BKTXT, " Doc.Header Text 25
BLART type ACGL_HEAD-BLART, "Document Type 2
BUKRS type BKPF-BUKRS, "Company Code4
END OF TY_HEADER,
* Structure Declaration for Item
BEGIN OF TY_ITEM,
BLDAT type CHAR10,"ACGL_HEAD-BLDAT,
HKONT type ACGL_ITEM-HKONT, "G/L account 10
SHKZG type ACGL_ITEM-SHKZG, "D/C 1
WRBTR type CHAR20,"ACGL_ITEM-WRBTR, "Amount in document currency 13
SGTXT type ACGL_ITEM-SGTXT, "Text 50
GSBER type ACGL_ITEM-GSBER, "Business area 4
KOSTL type ACGL_ITEM-KOSTL, "Cost center 10
PRCTR type ACGL_ITEM-PRCTR, "Profit center 10
END OF TY_ITEM,
* Structure Delcatation for source
BEGIN OF TY_UPLOAD,
F1 TYPE CHAR10,"4,
F2 TYPE CHAR10,
F3 TYPE CHAR10,"5,
F4 TYPE CHAR13,
F5 TYPE CHAR50,
F6 TYPE CHAR25,"16
F7 TYPE CHAR10,"25,
F8 TYPE CHAR10,
END OF TY_UPLOAD.
*&---------------------------------------------------------------------*
*& Source internal table Declaration
*&---------------------------------------------------------------------*
* Internal table declaration for header
DATA:T_HEADER TYPE STANDARD TABLE OF TY_HEADER,
* Internal table declaration for item
T_ITEM TYPE STANDARD TABLE OF TY_ITEM,
* Internal table declaration for source
T_UPLOAD TYPE STANDARD TABLE OF TY_UPLOAD,
t_error type standard table of ty_upload,
* Internal table declaration for target
T_BDCDATA TYPE STANDARD TABLE OF BDCDATA,
* Internal table declartion for message
T_MSG TYPE STANDARD TABLE OF BDCMSGCOLL,
*&---------------------------------------------------------------------*
*& Work area Declaration
*&---------------------------------------------------------------------*
* Work area declaration for header
W_HEADER TYPE TY_HEADER,
* Work area declaration for item
W_ITEM TYPE TY_ITEM,
* Work area declaration for source
W_UPLOAD TYPE TY_UPLOAD,
W_UPLOAD1 TYPE TY_UPLOAD,
* Work area declaration for target
W_BDCDATA TYPE BDCDATA,
* Work area declaration for message
W_MSG TYPE BDCMSGCOLL.
field-symbols : <fs>.
DATA : l_intern type standard table of alsmex_tabline.
data : l_index type i.
data: wa_intern LIKE alsmex_tabline .
DATA: l_date type sy-datum,
l_year(4) type c,
l_month(2) type c ,
l_day(2) type c.
DATA opt TYPE ctu_params.
opt-dismode = 'A'.
opt-defsize = 'X'.
opt-updmode = 'A'.
opt-nobinpt = 'X'.
opt-RACOMMIT = 'X' .
opt-NOBIEND = 'X' .
*&---------------------------------------------------------------------*
*& Selection screen Declaration
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
*PARAMETERS:P_FLNAME TYPE FILENAME.
PARAMETERS:P_FLNAME LIKE rlgrap-filename.
SELECTION-SCREEN END OF BLOCK B1.
************************************************************************
*At-selection-screen event
************************************************************************
*To provide Input help for file name
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FLNAME.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = SYST-CPROG
dynpro_number = SYST-DYNNR
IMPORTING
file_name = P_FLNAME.
*&---------------------------------------------------------------------*
*& Initialization Event Declaration
*&---------------------------------------------------------------------*
INITIALIZATION.
* Clear work areas
CLEAR:W_HEADER,
W_ITEM,
W_UPLOAD,
W_BDCDATA,
W_MSG.
* Refresh the tables
REFRESH:T_HEADER,
T_ITEM,
T_UPLOAD,
T_BDCDATA,
T_MSG.
*&---------------------------------------------------------------------*
*& Start of selection Declaration
*&---------------------------------------------------------------------*
START-OF-SELECTION.
* Upload the data
PERFORM SUB_UPLOAD_DATA.
* Pop bdcdata
PERFORM SUB_POP_BDCDATA.
*&---------------------------------------------------------------------*
*& Form SUB_UPLOAD_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM SUB_UPLOAD_DATA .
data : L_FLNAME TYPE rlgrap-filename.
L_FLNAME = P_FLNAME.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = L_FLNAME
I_BEGIN_COL = 1 "startcol
I_BEGIN_ROW = 1 "startrow
I_END_COL = 5000 "endcol
I_END_ROW = 1000000 "endrow
TABLES
INTERN = l_intern
* EXCEPTIONS
* INCONSISTENT_PARAMETERS = 1
* UPLOAD_OLE = 2
* OTHERS = 3
.
IF SY-SUBRC <> 0.
* message 'File should be in Excel' type 'E'.
* leave list-processing.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT l_intern into WA_intern.
MOVE WA_INTERN-COL TO L_INDEX.
ASSIGN COMPONENT L_INDEX OF STRUCTURE W_UPLOAD TO <FS>.
MOVE WA_INTERN-VALUE TO <FS>.
AT END OF ROW.
APPEND W_UPLOAD TO T_UPLOAD.
CLEAR W_UPLOAD.
ENDAT.
ENDLOOP.
LOOP AT T_UPLOAD INTO W_UPLOAD1.
***W_UPLOAD = W_UPLOAD1.
*** move W_UPLOAD-F1+0(2) to l_date.
*** move W_UPLOAD-F1+3(2) to l_month.
*** move W_UPLOAD-F1+6(4) to l_year.
*** concatenate l_month'/'l_date'/' l_year into W_UPLOAD-F1.
***
*** move W_UPLOAD-F3+0(2) to l_date.
*** move W_UPLOAD-F3+3(2) to l_month.
*** move W_UPLOAD-F3+6(4) to l_year.
*** concatenate l_month'/'l_date'/' l_year into W_UPLOAD-F3.
W_UPLOAD = W_UPLOAD1.
find '.' in W_UPLOAD-F1.
find '.' in W_UPLOAD-F3.
if sy-subrc = 0.
replace '.' with '/' into W_UPLOAD-F1.
replace '.' with '/' into W_UPLOAD-F3.
* CONDENSE W_UPLOAD-F1 NO-GAPS.
* CONDENSE W_UPLOAD-F3 NO-GAPS.
if sy-subrc = 0.
replace '.' with '/' into W_UPLOAD-F1.
replace '.' with '/' into W_UPLOAD-F3.
* CONDENSE W_UPLOAD-F1 NO-GAPS.
* CONDENSE W_UPLOAD-F3 NO-GAPS.
endif.
endif.
* Moving header data
AT NEW F1.
* W_HEADER-BUKRS = W_UPLOAD-F1.
W_HEADER-BLDAT = W_UPLOAD-F1.
W_HEADER-WAERS = W_UPLOAD-F2.
W_HEADER-BUDAT = W_UPLOAD-F3.
W_HEADER-LDGRP = W_UPLOAD-F4.
W_HEADER-XBLNR = W_UPLOAD-F5.
W_HEADER-BKTXT = W_UPLOAD-F6.
W_HEADER-BLART = W_UPLOAD-F7.
W_HEADER-BUKRS = W_UPLOAD-F8.
* W_HEADER-FDGRV = W_UPLOAD-F9.
* W_HEADER-WAERS = W_UPLOAD-F10.
APPEND W_HEADER TO T_HEADER.
CLEAR W_HEADER.
CONTINUE.
ENDAT.
* Moving the item data
* move W_UPLOAD-F1+0(2) to l_date.
* move W_UPLOAD-F1+3(2) to l_month.
* move W_UPLOAD-F1+6(4) to l_year.
* concatenate l_month'/'l_date'/' l_year into W_UPLOAD-F1.
find '.' in W_UPLOAD-F1.
if sy-subrc = 0.
replace '.' with '/' into W_UPLOAD-F1.
CONDENSE W_UPLOAD-F1 NO-GAPS.
if sy-subrc = 0.
replace '.' with '/' into W_UPLOAD-F1.
CONDENSE W_UPLOAD-F1 NO-GAPS.
endif.
endif.
* W_ITEM-BUKRS = W_UPLOAD-F1.
W_ITEM-BLDAT = W_UPLOAD-F1.
W_ITEM-HKONT = W_UPLOAD-F2. "G/L account
W_ITEM-SHKZG = W_UPLOAD-F3. "D/C
W_ITEM-WRBTR = W_UPLOAD-F4. "Amount in document currency
W_ITEM-SGTXT = W_UPLOAD-F5. "Text
W_ITEM-GSBER = W_UPLOAD-F6. "Business area
W_ITEM-KOSTL = W_UPLOAD-F7. "Cost center
W_ITEM-PRCTR = W_UPLOAD-F8.
APPEND W_ITEM TO T_ITEM.
CLEAR: W_ITEM, l_month, l_date, l_year.
ENDLOOP.
ENDFORM. " SUB_UPLOAD_DATA
*&---------------------------------------------------------------------*
*& Form SUB_POP_BDCDATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM SUB_POP_BDCDATA .
DATA:L_FIELD TYPE CHAR20," CHAR132."20,
L_N TYPE CHAR2.
* data: v_flines TYPE i,
* v_tabix TYPE sytabix,
* l_tabix TYPE sytabix.
* data :tc_lines type char4.
DATA : L_MSG TYPE STRING.
** data: LV_BLDAT TYPE SY-DATUM.
*DESCRIBE TABLE T_HEADER LINES v_flines.
LOOP AT T_HEADER INTO W_HEADER.
** LV_BLDAT = W_HEADER-BLDAT.
** CLEAR W_HEADER-BLDAT.
** WRITE LV_BLDAT TO W_HEADER-BLDAT.
REFRESH T_BDCDATA.
perform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'/ECCDE'.
perform bdc_field using 'ACGL_HEAD-BLDAT'
W_HEADER-BLDAT. "'03/22/2012'.
perform bdc_dynpro using 'SAPLACHD' '1000'.
perform bdc_field using 'BDC_CURSOR'
'BKPF-BUKRS'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'BKPF-BUKRS'
W_HEADER-BUKRS. "'3000'.
*perform bdc_transaction using 'FV50L'.
perform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'ACGL_HEAD-BLDAT'
W_HEADER-BLDAT. "'03/22/2012'.
perform bdc_field using 'ACGL_HEAD-WAERS'
W_HEADER-WAERS."'CNY'.
perform bdc_field using 'ACGL_HEAD-BUDAT'
W_HEADER-BUDAT."'03/28/2012'.
perform bdc_field using 'ACGL_HEAD-LDGRP'
W_HEADER-LDGRP."''.
perform bdc_field using 'ACGL_HEAD-XBLNR'
W_HEADER-XBLNR."'Salary of Feb'.
perform bdc_field using 'ACGL_HEAD-BKTXT'
W_HEADER-BKTXT."'Salary for Feb12'.
perform bdc_field using 'ACGL_HEAD-BLART'
W_HEADER-BLART."'ZZ'.
L_N = 1.
LOOP AT T_ITEM INTO W_ITEM WHERE BLDAT = W_HEADER-BLDAT.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-HKONT(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD"'ACGL_ITEM-HKONT(01)'
W_ITEM-HKONT." '50100010'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-SHKZG(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-SHKZG(01)'
W_ITEM-SHKZG."'S'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-WRBTR(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-WRBTR(01)'
W_ITEM-WRBTR."' 200'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-SGTXT(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-SGTXT(01)'
W_ITEM-SGTXT."'2月_基本工资'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-GSBER(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-GSBER(01)'
W_ITEM-GSBER."'3000'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-KOSTL(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-KOSTL(01)'
W_ITEM-KOSTL."'30001'.
perform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-PRCTR(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-PRCTR(02)'
W_ITEM-PRCTR."'p30005'.
*perform bdc_dynpro using 'SAPMF05A' '1001'.
*perform bdc_field using 'BDC_OKCODE'
* '/00'.
*perform bdc_field using 'BDC_CURSOR'
* 'ACGL_ITEM-PRCTR(02)'.
*perform bdc_field using 'ACGL_ITEM-HKONT(02)'
* '22120001'.
*perform bdc_field using 'ACGL_ITEM-SHKZG(02)'
* 'H'.
*perform bdc_field using 'ACGL_ITEM-WRBTR(02)'
* ' 200'.
*perform bdc_field using 'ACGL_ITEM-SGTXT(02)'
* '2月_基本工资'.
*perform bdc_field using 'ACGL_ITEM-GSBER(02)'
* '3000'.
*****************CLEAR L_FIELD.
*****************CONCATENATE 'ACGL_ITEM-PRCTR(0' L_N ')' INTO L_FIELD.
*****************perform bdc_field using L_FIELD "'ACGL_ITEM-PRCTR(02)'
***************** W_ITEM-PRCTR."'p30005'.
***PERFORM BDC_FIELD using 'BDC_OKCODE' " added newly
*** '=P+'. " added newly
* PERFORM bdc_field USING 'BDC_OKCODE'
* '=P+'.
L_N = L_N + 1.
* PERFORM bdc_field USING 'BDC_OKCODE'
***** '=P+'.
****************
*Loop at it_fill.
*L_N = L_N + 1.
IF L_N = 8. " Change this to greater than and try
L_N = 1.
perform bdc_dynpro using 'SAPMF05A' '1001'.
* perform bdc_field using 'BDC_OKCODE'
* '/00'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=P+'.
*CLEAR L_N.
*L_N = L_N + 1.
ENDIF.
*endloop.
* if L_N > 7.
* perform bdc_dynpro using 'SAPMF05A' '1001'.
* perform bdc_field using 'BDC_OKCODE'
* '=PP+N'.
*
* L_N = 8.
*** exit.
*** L_N = 1.
*** perform bdc_field using 'BDC_OKCODE'
*** '=P+'.
**
*** exit.
* endif.
*************
ENDLOOP.
perform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'=PBBP'.
*perform bdc_transaction using 'FV50L'.
REFRESH T_MSG.
CALL TRANSACTION 'FV50L' USING T_BDCDATA OPTIONS FROM opt
* MODE 'A'
MESSAGES INTO T_MSG.
IF SY-SUBRC <> 0.
APPEND W_UPLOAD TO T_ERROR.
ENDIF.
LOOP AT T_MSG INTO W_MSG.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = W_MSG-MSGID
LANG = SY-LANGU
NO = W_MSG-MSGNR
V1 = W_MSG-MSGV1
V2 = W_MSG-MSGV2
V3 = W_MSG-MSGV3
V4 = W_MSG-MSGV4
IMPORTING
MSG = L_MSG
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2
.
IF SY-SUBRC = 0.
WRITE : /2 W_UPLOAD-F1, 18 W_MSG-MSGTYP, 30 L_MSG.
ENDIF.
ENDLOOP.
ENDLOOP.
ENDFORM. " SUB_POP_BDCDATA
*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR W_BDCDATA.
W_BDCDATA-PROGRAM = PROGRAM.
W_BDCDATA-DYNPRO = DYNPRO.
W_BDCDATA-DYNBEGIN = 'X'.
APPEND W_BDCDATA TO T_BDCDATA.
ENDFORM. "BDC_DYNPRO
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
CLEAR W_BDCDATA.
W_BDCDATA-FNAM = FNAM.
W_BDCDATA-FVAL = FVAL.
APPEND W_BDCDATA TO T_BDCDATA.
ENDFORM. "BDC_FIELD
2012 Apr 12 12:11 PM
This is because u didnt do what i told u too... ur code is wrong... I have told u....
thats why it isnt working....
2012 Apr 12 12:59 PM
iam confused ELSE part here were to write header and item ..?
2012 Apr 12 1:00 PM
IAM CONFUSED IN ELSE PART... ABOUT header and item data ?
Else.
l_n = 7
Dont write the code u have written..
u shud write the code here to select the 7th line item
click on insert row (and dont do scroll, there is + button in the bottom)
Similar to this one.,...
PERFORM bdc_data USING 'BDC_OKCODE' '=0005'.
PERFORM bdc_data USING 'BDC_CURSOR' 'ACGL_ITEM-STATE(07)'.
PERFORM bdc_data USING 'INVFO-ACCNT' wa_header-newko.
PERFORM bdc_data USING 'INVFO-XBLNR' wa_header-xblnr.
PERFORM bdc_data USING 'ACGL_ITEM-MARKSP(04)' 'X'. "This selects the 7th line item
PERFORM bdc_screen USING 'SAPMF05A' '1100'.
PERFORM bdc_data USING 'BDC_OKCODE' '=0005'. "This Adds/inserts row
PERFORM bdc_data USING 'BDC_CURSOR' 'ACGL_ITEM-HKONT(04)'.
* PERFORM bdc_data USING 'RF05A-BUSCS' 'R'.
* PERFORM bdc_data USING 'BDC_SUBSCR' 'SAPLFDCB 0010PAGE'.
PERFORM bdc_data USING 'INVFO-ACCNT' wa_header-newko.
PERFORM bdc_data USING 'INVFO-XBLNR' wa_header-xblnr.
2012 Apr 12 1:07 PM
Which Header and Item Data??
Once u have started filling the table control.... then no need to write any extra code...
just prepare the BDC only for Table Control...
2012 Apr 12 1:12 PM
below ELSE part iam confused what to write there ..?
Else.
l_n = 7
Dont write the code u have written..
u shud write the code here to select the 7th line item
click on insert row (and dont do scroll, there is + button in the bottom)
Similar to this one.,...
PERFORM bdc_data USING 'BDC_OKCODE' '=0005'.
PERFORM bdc_data USING 'BDC_CURSOR' 'ACGL_ITEM-STATE(07)'.
PERFORM bdc_data USING 'INVFO-ACCNT' wa_header-newko.
PERFORM bdc_data USING 'INVFO-XBLNR' wa_header-xblnr.
PERFORM bdc_data USING 'ACGL_ITEM-MARKSP(04)' 'X'. "This selects the 7th line item
PERFORM bdc_screen USING 'SAPMF05A' '1100'.
PERFORM bdc_data USING 'BDC_OKCODE' '=0005'. "This Adds/inserts row
PERFORM bdc_data USING 'BDC_CURSOR' 'ACGL_ITEM-HKONT(04)'.
* PERFORM bdc_data USING 'RF05A-BUSCS' 'R'.
* PERFORM bdc_data USING 'BDC_SUBSCR' 'SAPLFDCB 0010PAGE'.
PERFORM bdc_data USING 'INVFO-ACCNT' wa_header-newko.
PERFORM bdc_data USING 'INVFO-XBLNR' wa_header-xblnr.
2012 Apr 12 1:22 PM
there would be a okcode to select a line item.. and then to click on + button
we need to write that code in else part...
Go to SHDB...
Make a Recording how to select line item and click on + button... i guess this u know...
2012 Apr 12 4:02 PM
2012 Apr 12 8:52 PM
Hi Mahesh,
| l_count(5) | TYPE n, | |
| l_mod1 | TYPE f, | |
| l_mod | TYPE i, | |
| l_pos | TYPE i, |
In the loop at the item level, use this code.
| l_count = l_count + 1. | ||
| IF l_count GT 7. | ||
| l_pos = l_count MOD 7. " REMAINDER | ||
| l_mod1 = l_count / 7. " QU0TIENT | ||
| l_mod = TRUNC( l_mod1 ). | ||
| IF l_pos = 1." This IF condition may vary, pls adjust to ur requirement | ||
| l_count = l_pos + 1. | ||
| ELSE. | ||
| l_count = l_pos. | ||
| ENDIF. | ||
| IF l_count EQ 0. | ||
| l_mod = l_mod - 1. | ||
| l_count = '7'. | ||
| ENDIF. | ||
| ENDIF. | ||
| IF l_mod ne 0. | ||
| DO l_mod TIMES. " For scrolling based on no. of items in tbl ctrl | ||
| PERFORM bdc_dynpro USING 'SAPMF05A' | '1001'. | |
| perform bdc_field using 'BDC_OKCODE' | '=P+'. | |
| ENDDO. | ||
| PERFORM bdc_dynpro USING 'SAPMF05A' | '1001'. | |
| ELSE. " when the count is less than 7 no need to scroll. | ||
| PERFORM bdc_dynpro USING 'SAPMF05A' | '1001'. | |
| ENDIF. |
After these lines add your code of concatenating the item fields with the numbers (l_count) here and build the bdc_field.
CONCATENATE field_name '(' l_count ')' INTO field.
PERFORM bdc_field field value.
It will work now.
Better ctu_params with screen default to 'X' in call transaction, then it might not be a problem for different guis ( table control lines ).
Regards,
Raja Sekhar
2012 Apr 13 6:33 AM
This is my code i did changes as you said but its not working.. its over writing on first uploaded 7 records but scroller is not moving down and placing new record.
LOOP AT T_HEADER INTO W_HEADER.
REFRESH T_BDCDATA.
perform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'/ECCDE'.
perform bdc_field using 'ACGL_HEAD-BLDAT'
W_HEADER-BLDAT. "'03/22/2012'.
perform bdc_dynpro using 'SAPLACHD' '1000'.
perform bdc_field using 'BDC_CURSOR'
'BKPF-BUKRS'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'BKPF-BUKRS'
W_HEADER-BUKRS. "'3000'.
*perform bdc_transaction using 'FV50L'.
perform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'ACGL_HEAD-BLDAT'
W_HEADER-BLDAT. "'03/22/2012'.
perform bdc_field using 'ACGL_HEAD-WAERS'
W_HEADER-WAERS."'CNY'.
perform bdc_field using 'ACGL_HEAD-BUDAT'
W_HEADER-BUDAT."'03/28/2012'.
perform bdc_field using 'ACGL_HEAD-LDGRP'
W_HEADER-LDGRP."''.
perform bdc_field using 'ACGL_HEAD-XBLNR'
W_HEADER-XBLNR."'Salary of Feb'.
perform bdc_field using 'ACGL_HEAD-BKTXT'
W_HEADER-BKTXT."'Salary for Feb12'.
perform bdc_field using 'ACGL_HEAD-BLART'
W_HEADER-BLART."'ZZ'.
L_N = 0.
LOOP AT T_ITEM INTO W_ITEM WHERE BLDAT = W_HEADER-BLDAT.
CLEAR L_FIELD.
L_N = L_N + 1.
if L_N > 7.
l_pos = L_N MOD 7. " REMAINDER
l_mod1 = L_N / 7. " QU0TIENT
l_mod = TRUNC( l_mod1 ).
IF l_pos = 1.
L_N = l_pos + 1.
ELSE.
L_N = l_pos.
ENDIF.
IF L_N EQ 0.
l_mod = l_mod - 1.
L_N = 7.
ENDIF.
ENDIF.
IF l_mod ne 0.
DO l_mod TIMES.
perform bdc_dynpro using 'SAPMF05A' '1001'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=P+'.
ENDDO.
perform bdc_dynpro using 'SAPMF05A' '1001'.
ELSE.
perform bdc_dynpro using 'SAPMF05A' '1001'.
ENDIF.
CONCATENATE 'ACGL_ITEM-HKONT(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD"'ACGL_ITEM-HKONT(01)'
W_ITEM-HKONT." '50100010'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-SHKZG(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-SHKZG(01)'
W_ITEM-SHKZG."'S'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-WRBTR(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-WRBTR(01)'
W_ITEM-WRBTR."' 200'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-SGTXT(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-SGTXT(01)'
W_ITEM-SGTXT."'2月_基本工资'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-GSBER(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-GSBER(01)'
W_ITEM-GSBER."'3000'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-KOSTL(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-KOSTL(01)'
W_ITEM-KOSTL."'30001'.
perform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-PRCTR(0' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-PRCTR(02)'
W_ITEM-PRCTR."'p30005'.
ENDLOOP.
perform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'=PBBP'.
*perform bdc_transaction using 'FV50L'.
REFRESH T_MSG.
CALL TRANSACTION 'FV50L' USING T_BDCDATA OPTIONS FROM opt
* MODE 'A'
MESSAGES INTO T_MSG.
2012 Apr 13 6:51 AM
Hi Mahesh,
What is the type and length you used for l_n in your program.
Give the length as l_n(2) type n and remove '0' in all the concatenate statements.
Like CONCATENATE 'ACGL_ITEM-KOSTL(0' L_N ')' INTO L_FIELD.
Now it will work. If not try do it like below.
Change your code with this and try. Just comment the If condition and give only l_n = l_pos.
* IF l_pos = 1.
* L_N = l_pos + 1. " while page down the last row of the previous table control screen will be at first line in some table control screens, so we are making the second line as input...
* ELSE.
L_N = l_pos." For first line of next page down
* ENDIF.
2012 Apr 13 6:51 AM
Dont use P+ okcode... because this transaction doesnt know P+ okcode. So even if u write it, it wont work properly...
Use okcode 0005 which if for inserting a new record..
2012 Apr 13 7:29 AM
hi still not working same thing records over writing ..after your suggested changes both of them .
LOOP AT T_ITEM INTO W_ITEM WHERE BLDAT = W_HEADER-BLDAT.
CLEAR L_FIELD.
L_N = L_N + 1.
if L_N > 7.
l_pos = L_N MOD 7. " REMAINDER
l_mod1 = L_N / 7. " QU0TIENT
l_mod = TRUNC( l_mod1 ).
** IF l_pos = 1.
** L_N = l_pos + 1.
** ELSE.
L_N = l_pos.
** ENDIF.
IF L_N EQ 0.
l_mod = l_mod - 1.
L_N = 7.
ENDIF.
ENDIF.
IF l_mod ne 0.
DO l_mod TIMES.
perform bdc_dynpro using 'SAPMF05A' '1001'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=0005'."'=P+'.
ENDDO.
perform bdc_dynpro using 'SAPMF05A' '1001'.
ELSE.
perform bdc_dynpro using 'SAPMF05A' '1001'.
ENDIF.
2012 Apr 13 7:39 AM
Before applying 005 okcode into the code, you need to select the last line item...and BDC wud be like...
perform bdc_dynpro using 'SAPMF05A' '1001'.
PERFORM bdc_data USING 'ACGL_ITEM-MARKSP(07)' 'X'.
perform bdc_dynpro using 'SAPMF05A' '1001'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=0005'."'=P+'.
2012 Apr 13 7:40 AM
2012 Apr 13 7:43 AM
Before applying 005 okcode into the code, you need to select the last line item...and BDC wud be like...
perform bdc_dynpro using 'SAPMF05A' '1001'.
PERFORM bdc_data USING 'ACGL_ITEM-MARKSP(07)' 'X'.
perform bdc_dynpro using 'SAPMF05A' '1001'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=0005'."'=P+'.
2012 Apr 13 7:44 AM
last line item or line items i mean in each row i am filling 5 columns data.
2012 Apr 13 7:48 AM
while filling the table control, after inputting how many records, when do u need to scroll,
Say after 5th record u need to scroll... so ur line item is 5th (SO line Item means 5th record and not 5th column)
2012 Apr 13 7:53 AM
those are my line item
CONCATENATE 'ACGL_ITEM-HKONT(' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD"'ACGL_ITEM-HKONT(01)'
W_ITEM-HKONT." '50100010'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-SHKZG(' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-SHKZG(01)'
W_ITEM-SHKZG."'S'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-WRBTR(' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-WRBTR(01)'
W_ITEM-WRBTR."' 200'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-SGTXT(' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-SGTXT(01)'
W_ITEM-SGTXT."'2月_基本工资'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-GSBER(' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-GSBER(01)'
W_ITEM-GSBER."'3000'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-KOSTL(' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-KOSTL(01)'
W_ITEM-KOSTL."'30001'.
perform bdc_dynpro using 'SAPMF05A' '1001'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
CLEAR L_FIELD.
CONCATENATE 'ACGL_ITEM-PRCTR(' L_N ')' INTO L_FIELD.
perform bdc_field using L_FIELD "'ACGL_ITEM-PRCTR(02)'
W_ITEM-PRCTR."'p30005'.
2012 Apr 13 1:40 PM
2012 Apr 13 2:00 PM
Hi Mahesh,
By BDC it will be little bit complex if you go for bapi it makes so easy for FB60 tcode.
'BAPI_ACC_DOCUMENT_POST'.
2012 Apr 18 7:37 AM