‎2008 Nov 14 12:35 PM
Hello,
I am new in BDC please any body help me .
I am using cj40 transaction to transfer the data.
If possible can u send code.
Regards
read the rules before posting
Edited by: Vijay Babu Dudla on Nov 14, 2008 10:29 AM
‎2008 Nov 14 12:37 PM
Hi
If you do the recording using...SHDB tcode...you will get the code from there by generating a program from the recording. Then pass the internal table values to the subroutines in place of the values...and your BDC program will be running.
Vishwa.
‎2008 Nov 14 12:37 PM
Hi
If you do the recording using...SHDB tcode...you will get the code from there by generating a program from the recording. Then pass the internal table values to the subroutines in place of the values...and your BDC program will be running.
Vishwa.
‎2008 Nov 14 12:45 PM
This is my code please make it some corrections please.................
Report Ztestpro
no standard page heading line-size 255.
TYPES : BEGIN OF TY_HEAD,
POSID LIKE PRPS-POSID,
VERSN LIKE BPDY-VERSN,
END OF TY_HEAD.
TYPES : BEGIN OF TY_ITEM,
TYPPS LIKE RK70L-TYPPS,
HERK2 LIKE RK70L-HERK2,
HERK3 LIKE RK70L-HERK3,
MENGE LIKE RK70L-MENGE,
LPREIS LIKE RK70L-LPREIS,
END OF TY_ITEM.
TYPES : BEGIN OF TY_FINAL,
POSID LIKE PRPS-POSID,
VERSN LIKE BPDY-VERSN,
TYPPS LIKE RK70L-TYPPS,
HERK2 LIKE RK70L-HERK2,
HERK3 LIKE RK70L-HERK3,
MENGE LIKE RK70L-MENGE,
LPREIS LIKE RK70L-LPREIS,
END OF TY_FINAL.
data:it_bdc type bdcdata occurs 0 with header line.
DATA : IT_FINAL TYPE TABLE OF TY_FINAL WITH HEADER LINE,
IT_HEAD TYPE TABLE OF TY_HEAD WITH HEADER LINE,
IT_ITEM TYPE TABLE OF TY_ITEM WITH HEADER LINE.
IT_bdcdata TYPE TABLE OF bdcdata WITH HEADER LINE.
Data:
wa_final type ty_final,
wa_head type ty_head,
wa_item type ty_item,
wa_bdcdata type bdcdata.
wa_bdcmsgcoll type bdcmsgcoll.
Data:
program type syst-BATCH,
dynpro type syst-dynnr,
fnam type syst-sfnam,
fval type syst-sfnam.
selection-screen begin of block b1 with frame.
Parameters:P_file type rlgrap-filename.
selection-screen end of block b1.
VALDIATIONS
at selection-screen on value-request for p_file.
perform f4_filename using p_file.
AT SELECTION-SCREEN ON P_file.
IF P_file EQ SPACE.
MESSAGE E000(8I) WITH 'ENTER A VALID INPUT FILE'.
ENDIF.
At selection-screen on value-request for p_file.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = p_file.
start-of-selection.
perform upload_data using p_file.
perform fill_bdcdata.
&----
*& Form UPLOAD_DATA
&----
text
----
--> p1 text
<-- p2 text
----
FORM UPLOAD_DATA using p_file.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
filename = p_file
filetype = 'DAT'
TABLES
data_tab = it_final
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
no_authority = 10
OTHERS = 11.
IF sy-subrc <> 0.
MESSAGE e000(z3) WITH 'FILE NOT UPLOADED'.
ENDIF.
ENDFORM. " UPLOAD_DATA
*start-of-selection.
*
*perform open_group.
&----
*& Form FILL_BDCDATA
&----
text
----
--> p1 text
<-- p2 text
----
FORM FILL_BDCDATA .
Loop at it_final into wa_final .
perform bdc_dynpro using 'SAPMKBUD'(002) '0200'.
perform bdc_field using 'BDC_CURSOR'
'PRPS-POSID'.
perform bdc_field using 'BDC_OKCODE'
'=EINK'.
perform bdc_field using 'PRPS-POSID'
it_final-posid.
perform bdc_field using 'BPDY-VERSN'
it_final-versn.
perform bdc_dynpro using 'SAPLKBPP'(003) '0320'.
perform bdc_field using 'BDC_CURSOR'
'BPDY-STUFE(01)'.
perform bdc_field using 'BDC_OKCODE'
'=KALK'.
perform bdc_field using 'DROPT-PTIME'
'1'.
perform bdc_field using 'RCJ_MARKL-MARK(01)'
'X'.
perform bdc_dynpro using 'SAPLKKDI'(004) '1301'.
perform bdc_field using 'BDC_CURSOR'
'RK70L-LPREIS(01)'.
perform bdc_field using 'BDC_OKCODE'
'=SICH'.
perform bdc_field using 'RK70E-LST_SETNR'
' 1'.
perform bdc_field using 'RK70L-TYPPS(01)'
IT_final-TYPPS.
perform bdc_field using 'RK70L-HERK2(01)'
IT_final-HERK2.
perform bdc_field using 'RK70L-HERK3(01)'
IT_final-HERK3.
perform bdc_field using 'RK70L-MENGE(01)'
IT_final-MENGE.
perform bdc_field using 'RK70L-LPREIS(01)'
IT_final-LPREIS.
perform bdc_dynpro using 'SAPLKBPP'(003) '0320'.
perform bdc_field using 'BDC_CURSOR'
'BPDY-STUFE(01)'.
perform bdc_field using 'BDC_OKCODE'
'=SAVE'.
perform bdc_field using 'DROPT-PTIME'
'1'.
CALL TRANSACTION 'CJ40' USING it_bdcdata MODE 'A'.
ENDLOOP.
ENDFORM. " FILL_BDCDATA
&----
*& Form BDC_DYNPRO
&----
text
----
-->P_0289 text
-->P_0290 text
----
FORM BDC_DYNPRO USING VALUE(P_0289)
VALUE(P_0290).
CLEAR IT_BDCDATA.
IT_BDCDATA-PROGRAM = PROGRAM.
IT_BDCDATA-DYNPRO = DYNPRO.
IT_BDCDATA-DYNBEGIN = 'X'.
APPEND IT_BDCDATA.
ENDFORM. " BDC_DYNPRO
&----
*& Form BDC_FIELD
&----
text
----
-->P_0294 text
-->P_0295 text
----
FORM BDC_FIELD USING VALUE(P_0294)
VALUE(P_0295).
IF FVAL IS NOT INITIAL. "NODATA.
CLEAR IT_BDCDATA.
IT_BDCDATA-FNAM = FNAM.
IT_BDCDATA-FVAL = FVAL.
APPEND IT_BDCDATA.
endif.
ENDFORM. " BDC_FIELD
‎2008 Nov 14 12:47 PM
‎2008 Nov 14 12:55 PM
‎2008 Nov 14 12:56 PM
I can understand that..but there should be some error, right?? It should say something is not right...when you execute or press F8 button??
Vishwa.
‎2008 Nov 14 1:08 PM
Hi,
It is not giving any error it is syntatically correct but the data is not uploading to the database table.
Regards
‎2008 Nov 14 12:39 PM
Hi you first do recording using transaction SHDB for tcode that you want to use...it will make a program.
then use CALL TRANSACTION 'NAME'
USING BDCDATA ,
MODE 'A',
RETURN 'TABLE NAME'.
‎2008 Nov 14 12:46 PM
Report Ztestpro
no standard page heading line-size 255.
TYPES : BEGIN OF TY_HEAD,
POSID LIKE PRPS-POSID,
VERSN LIKE BPDY-VERSN,
END OF TY_HEAD.
TYPES : BEGIN OF TY_ITEM,
TYPPS LIKE RK70L-TYPPS,
HERK2 LIKE RK70L-HERK2,
HERK3 LIKE RK70L-HERK3,
MENGE LIKE RK70L-MENGE,
LPREIS LIKE RK70L-LPREIS,
END OF TY_ITEM.
TYPES : BEGIN OF TY_FINAL,
POSID LIKE PRPS-POSID,
VERSN LIKE BPDY-VERSN,
TYPPS LIKE RK70L-TYPPS,
HERK2 LIKE RK70L-HERK2,
HERK3 LIKE RK70L-HERK3,
MENGE LIKE RK70L-MENGE,
LPREIS LIKE RK70L-LPREIS,
END OF TY_FINAL.
data:it_bdc type bdcdata occurs 0 with header line.
DATA : IT_FINAL TYPE TABLE OF TY_FINAL WITH HEADER LINE,
IT_HEAD TYPE TABLE OF TY_HEAD WITH HEADER LINE,
IT_ITEM TYPE TABLE OF TY_ITEM WITH HEADER LINE.
IT_bdcdata TYPE TABLE OF bdcdata WITH HEADER LINE.
Data:
wa_final type ty_final,
wa_head type ty_head,
wa_item type ty_item,
wa_bdcdata type bdcdata.
wa_bdcmsgcoll type bdcmsgcoll.
Data:
program type syst-BATCH,
dynpro type syst-dynnr,
fnam type syst-sfnam,
fval type syst-sfnam.
selection-screen begin of block b1 with frame.
Parameters:P_file type rlgrap-filename.
selection-screen end of block b1.
VALDIATIONS
at selection-screen on value-request for p_file.
perform f4_filename using p_file.
AT SELECTION-SCREEN ON P_file.
IF P_file EQ SPACE.
MESSAGE E000(8I) WITH 'ENTER A VALID INPUT FILE'.
ENDIF.
At selection-screen on value-request for p_file.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = p_file.
start-of-selection.
perform upload_data using p_file.
perform fill_bdcdata.
&----
*& Form UPLOAD_DATA
&----
text
----
--> p1 text
<-- p2 text
----
FORM UPLOAD_DATA using p_file.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
filename = p_file
filetype = 'DAT'
TABLES
data_tab = it_final
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
no_authority = 10
OTHERS = 11.
IF sy-subrc <> 0.
MESSAGE e000(z3) WITH 'FILE NOT UPLOADED'.
ENDIF.
ENDFORM. " UPLOAD_DATA
*start-of-selection.
*
*perform open_group.
&----
*& Form FILL_BDCDATA
&----
text
----
--> p1 text
<-- p2 text
----
FORM FILL_BDCDATA .
Loop at it_final into wa_final .
perform bdc_dynpro using 'SAPMKBUD'(002) '0200'.
perform bdc_field using 'BDC_CURSOR'
'PRPS-POSID'.
perform bdc_field using 'BDC_OKCODE'
'=EINK'.
perform bdc_field using 'PRPS-POSID'
it_final-posid.
perform bdc_field using 'BPDY-VERSN'
it_final-versn.
perform bdc_dynpro using 'SAPLKBPP'(003) '0320'.
perform bdc_field using 'BDC_CURSOR'
'BPDY-STUFE(01)'.
perform bdc_field using 'BDC_OKCODE'
'=KALK'.
perform bdc_field using 'DROPT-PTIME'
'1'.
perform bdc_field using 'RCJ_MARKL-MARK(01)'
'X'.
perform bdc_dynpro using 'SAPLKKDI'(004) '1301'.
perform bdc_field using 'BDC_CURSOR'
'RK70L-LPREIS(01)'.
perform bdc_field using 'BDC_OKCODE'
'=SICH'.
perform bdc_field using 'RK70E-LST_SETNR'
' 1'.
perform bdc_field using 'RK70L-TYPPS(01)'
IT_final-TYPPS.
perform bdc_field using 'RK70L-HERK2(01)'
IT_final-HERK2.
perform bdc_field using 'RK70L-HERK3(01)'
IT_final-HERK3.
perform bdc_field using 'RK70L-MENGE(01)'
IT_final-MENGE.
perform bdc_field using 'RK70L-LPREIS(01)'
IT_final-LPREIS.
perform bdc_dynpro using 'SAPLKBPP'(003) '0320'.
perform bdc_field using 'BDC_CURSOR'
'BPDY-STUFE(01)'.
perform bdc_field using 'BDC_OKCODE'
'=SAVE'.
perform bdc_field using 'DROPT-PTIME'
'1'.
CALL TRANSACTION 'CJ40' USING it_bdcdata MODE 'A'.
ENDLOOP.
ENDFORM. " FILL_BDCDATA
&----
*& Form BDC_DYNPRO
&----
text
----
-->P_0289 text
-->P_0290 text
----
FORM BDC_DYNPRO USING VALUE(P_0289)
VALUE(P_0290).
CLEAR IT_BDCDATA.
IT_BDCDATA-PROGRAM = PROGRAM.
IT_BDCDATA-DYNPRO = DYNPRO.
IT_BDCDATA-DYNBEGIN = 'X'.
APPEND IT_BDCDATA.
ENDFORM. " BDC_DYNPRO
&----
*& Form BDC_FIELD
&----
text
----
-->P_0294 text
-->P_0295 text
----
FORM BDC_FIELD USING VALUE(P_0294)
VALUE(P_0295).
IF FVAL IS NOT INITIAL. "NODATA.
CLEAR IT_BDCDATA.
IT_BDCDATA-FNAM = FNAM.
IT_BDCDATA-FVAL = FVAL.
APPEND IT_BDCDATA.
endif.
ENDFORM. " BDC_FIELD
‎2008 Nov 14 12:45 PM