Validation for BDC program
hi,
In BDC programe I have to check (or) validate the file path at selection screen events .
if the selected file is wrong error message should be triggered. how i can do this.
with regards,
Srinath
Hello Reddy,
In the following example,
purchase order fields are taken in through a text-file, if the fields do not match the fields of internal table, then just throw an error in GUI_UPLOAD saying , 'FILE CANNOT BE UPLOADED' or say 'UPLOADING FAILED'.
* STRUCTURE FOR PURCHASE ORDER TABLE *
TYPES:
BEGIN OF type_s_mat,
eeind TYPE rm06b-eeind, " Delivery Date
txz01 TYPE eban-txz01, " Short Text
menge TYPE eban-menge, " Quantity
meins TYPE eban-meins, " Units
preis TYPE eban-preis, " Price
END OF type_s_mat. " BEGIN OF TYPE_S_MAT
* FIELD STRING FOR PURCHASE ORDER TABLE *
DATA:
fs_mat TYPE type_s_mat.
* INTERNAL TABLE FOR PURCHASE ORDER TABLE *
DATA:
t_mat LIKE
STANDARD TABLE
OF fs_mat.
* INTERNAL TABLE FOR BATCH DATA TRANSFER *
DATA:
t_bdc TYPE
STANDARD TABLE
OF bdcdata
WITH HEADER LINE.
* INTERNAL TABLE FOR MESSAGES *
DATA:
t_messages TYPE
STANDARD TABLE
OF bdcmsgcoll
WITH HEADER LINE.
* Work Variables *
DATA:
w_filename TYPE rlgrap-filename, " Selected File-Name
w_msg(72) TYPE c, " Messages
w_filename1 TYPE string. " Full-Path
* INITIALIZATION *
INITIALIZATION.
PARAMETERS p_file(128). " Name of File to be opened
* AT SELECTION-SCREEN ON VALUE-REQUEST *
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM open_mat_file.
p_file = w_filename.
* START-OF-SELECTION *
START-OF-SELECTION.
IF p_file IS INITIAL.
MESSAGE 'No File Selected' TYPE 'S' DISPLAY LIKE 'E'.
ELSE.
PERFORM open_file.
ENDIF. " IF P_FILE IS INITIAL
*& Form open_mat_file
* This Subroutine opens Material File of the Presentation Server.
* This Subroutine has got no Interface Parameters.
FORM open_mat_file .
CALL FUNCTION 'F4_FILENAME'
* EXPORTING
* PROGRAM_NAME = SYST-CPROG
* DYNPRO_NUMBER = SYST-DYNNR
* FIELD_NAME = ' '
IMPORTING
file_name = w_filename.
ENDFORM. " FORM OPEN_MAT_FILE
*& Form open_file
* This Subroutine facilitates file upload on Presentation Server.
* This Subroutine has got no Interface Parameters.
FORM open_file .
w_filename1 = w_filename.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = w_filename1
filetype = 'ASC'
* has_field_separator = ' '
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = t_mat
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 'Uploading Failed' TYPE 'S' DISPLAY LIKE 'E'.
ELSE.
PERFORM populating_bdc.
ENDIF. " IF SY-SUBRC NE 0
ENDFORM. " FORM OPEN_FILE
*& Form populating_bdc
* This Subroutine Populates data in Transaction ME51
* This Subroutine has got no Interface Parameters.
FORM populating_bdc .
LOOP AT t_mat INTO fs_mat.
PERFORM screens USING 'SAPMM06B' '0100'.
PERFORM fields USING 'EBAN-BSART' 'NB'.
PERFORM fields USING 'EBAN-KNTTP' 'X'.
PERFORM fields USING 'RM06B-LPEIN' 'T'.
PERFORM fields USING 'RM06B-EEIND' fs_mat-eeind.
PERFORM fields USING 'EBAN-WERKS' '1000'.
PERFORM fields USING 'EBAN-EKGRP' '100'.
PERFORM fields USING 'EBAN-MATKL' '006'.
PERFORM fields USING 'BDC_OKCODE' '/00'.
PERFORM screens USING 'SAPMM06B' '0106'.
PERFORM fields USING 'EBAN-TXZ01' fs_mat-txz01.
PERFORM fields USING 'EBAN-MENGE' fs_mat-menge.
PERFORM fields USING 'EBAN-MEINS' fs_mat-meins.
PERFORM fields USING 'BDC_OKCODE' '/00'.
PERFORM screens USING 'SAPMM06B' '0102'.
PERFORM fields USING 'EBAN-PREIS' fs_mat-preis.
PERFORM fields USING 'BDC_OKCODE' '/00'.
PERFORM screens USING 'SAPMM06B' '0505'.
PERFORM fields USING 'COBL-KOSTL' '1000'.
PERFORM fields USING 'BDC_OKCODE' '/00'.
PERFORM screens USING 'SAPMM06B' '0106'.
PERFORM fields USING 'BDC_OKCODE' 'BU'.
CALL TRANSACTION 'ME51' USING t_bdc MODE 'A' MESSAGES INTO
t_messages.
IF sy-subrc EQ 0.
LOOP AT t_messages.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = t_messages-msgid
lang = sy-langu
no = t_messages-msgnr
v1 = t_messages-msgv1
v2 = t_messages-msgv2
v3 = t_messages-msgv3
v4 = t_messages-msgv4
IMPORTING
msg = w_msg
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
WRITE:/ w_msg.
ENDIF. " IF SY-SUBRC <> 0
ENDLOOP. " LOOP AT T_MAT INTO FS_MAT
ENDIF. " IF SY-SUBRC EQ 0
ENDLOOP. " LOOP T_MAT INTO FS_MAT
ENDFORM. " FORM POPULATING_BDC
*& Form screens
* This Subroutine populates program name and screen numbers.
* -->VALUE(P_PROG) PROGRAM NAME
* -->VALUE(P_SCRNO) SCREEN NUMBER
FORM screens USING value(p_prog) value(p_scrno).
t_bdc-program = p_prog.
t_bdc-dynpro = p_scrno.
t_bdc-dynbegin = 'X'.
APPEND t_bdc.
ENDFORM. " FORM SCREENS
*& Form fields
* This Subroutine populates Field Value and Field name
* -->VALUE(P_FNAM) Field Name
* -->VALUE(P_FVAL) Field Value
FORM fields USING value(p_fnam) value(p_fval).
t_bdc-fnam = p_fnam.
t_bdc-fval = p_fval.
APPEND t_bdc.
ENDFORM. " FORM FIELDS
Hope the above given example, helps you.
Thanks: Zahackson
Similar Messages
-
F-32 possible for bdc program.
Hi experts...
F-32 - CLEAR CUSTOMER, is it possible to write bdc program for uploading.
If it is possible then what is the procedure to be followed.
if it is a full clearing or partial clearing against vendor open items?
Thanks in advance.
Arvind nnHi,
Cleared customr/vendor data stored in BSAD/BSAK table. Clearing is different process which is done by functional consultant. Once clear the vendor/custome then only data stored in tables. Partial clear data doesn't contains on these tale. So i m also not confirm that whether we write the bdc program for these tcode. But i don't think we will write the bdc program for clear document.
Regds,
Rakesh -
Recording TCode for BDC program
Hi ALL,
I have a problem in recording GS01 tcode.
I have to a table control in GS01 tcode.
After some rows again i need to update the data.
How can i record this and write BDC program for the same.Hi
To uplaod the data using the table control,if number of line are more then screen.
Then use the P+ in u r code.
let assume that u can see 10 rows on screen.once the count reachs the 10 then do P+ then
new line will come and after P+ clear u r counter. -
Handling screen resolution fields in me21 for bdc programming
I need to use BDC program for ME21 for that how to handle the screen resolution,
i know CTU_PARAMS structure is there ,but how to use them, please send the model code. for handling check boxes fields.answered
-
Bdc program for uploading region data in sales analysis
hi expert,
i want to upload the region data in sales transaction show that i want to analysis the area wise sales detail for different material.for this which *transaction code* ,i should use for recording.can any body provide me example for BDC Program.
Thank youhi expert,
i want to upload the region data in sales transaction show that i want to analysis the area wise sales detail for different material.for this which *transaction code* ,i should use for recording.can any body provide me example for BDC Program.
Thank you -
Can anyone just tell me the steps which one follows before going for a BDC Program. i mean right frm the starting if any Company want to implement SAP.
HI,
For a BDC upload you need to write a program which created BDC sessions.
Steps:
1. Work out the transaction you would use to create the data manually.
2. Use transaction SHDB to record the creation of one material master data.
Click the New recording button or the Menu - Recording - Create
3. Save the recording, and then go back a screen and go to the overview.
4. Select the recording and click on Edit - Create Program. Give the program a Z name, and select transfer from recording.
5. Edit the program. You will see that all the data you entered is hard-coded into the program. You need to make the following changes:
5.1 After the start-of-selection, Call ws_upload to upload the file (the excel file needs to be saved as TAB separated).
5.2 After the open-group, Loop on the uploaded data. For each line, perform validation checks on the data, then modify the perform bdc_field commands to use the file data.
5.3. After perform bdc_transaction, add the endloop.
Execute the program. It will have options to create a batch session or to process directly.
<b>These are all my finds . Might be it will be useful to you.</b>
Regards
Sudheer
Direct call of transactions, session handling:
/nxxxx This terminates the current transaction, and starts transaction xxxx
/n This terminates the transaction. This generally corresponds to pressing F15 to go back.
/nend This termiantes all separate sessions and logs off (corresponds to System - Logoff).
/nex This terminates all separate sessions and logs off immediately (without any warning!).
/oxxxx This opens a new session and starts transaction xxxx in This session.
/o This lists existing sessions and allows deletion or opening of a new session.
/i This terminates the current session (corresponds to System End
/i1, /i2,... This terminates the session with the number given.
.xyzw Fast path: 'xyzw' refers to the underlined letters in the menus. This type of navigation is uncommon and is provided more for emergencies (such as a defective mouse).
Batch
The following commands can be entered in correction mode ('Process in foreground' or 'Display errors only') when processing a batch input session:
/n This terminates the current batch input transaction and characterizes it as
/bdel This deletes the current batch input transaction.
/bend This terminates batch input processing and sets the session to Failed
/bda This switches from Display errors only to Process in foreground
/bde This switches from Process in foreground to Display errors only
ABAP/4
/h This switches into debugging mode.
/hs This switches into debugging mode and activates the debugging of system functions.
Buffer
WARNING: Resetting buffers can significantly change the performance of the entire system for a long time.
It should therefore only be used where there is a good reason tdso. As of release 3.0B system administator authorization is required (authorization object (S_ADMI_FCD). The action is noted in the system log.
/$SYNC This resets all buffers of the application server
/$CUA This resets the CUA buffer of the application server
/$TAB This resets the TABLE buffers of the application server
/$NAM This resets the nametab buffer of the application server
/$DYNP This resets the screen buffer of the application server -
Standard BDC program used for FI
hi all ,
i would like to know the standard BDC program used in FI , like for tcode fb01 or somethings else.
Appreciate for any segguestion.
thanks and regards.hi siddu m
thanks for replay ,
i have anohter question
provided the transaction A was contianed in the first batch file,
and also contained in the second batch file , how the tcode treated as the duplicate posting ?
many thanks -
Running BDC program in background for the transaction VL02N
Hi All,
I have coded a BDC program (call transaction method) for the transaction code VL02N. I can able to run the program manually & successfully. But if I execute the program in background(SM36), it is going to dump giving CNTL_ERROR.
Note: I am not using any of the GUI_UPLOAD, GUI_DOWNLOAD funciton modules in the program. But I am using the FTP command funtion modules like( FTP_COMMAND, FTP_CONNECT, FTP_DISCONNECT and FTP_SERVER_TO_R/3).
<removed_by_moderator>
Thanks in advance.
Ramesh.
Edited by: Julius Bussche on Jul 8, 2008 5:55 PMVL02N is an enjoy transaction. You cant run it in background. Please try VL02.
Thanks
Romit -
Problem in creating a BDC program for transaction cj20n(project sytem)
Hi all,
I am trying to create project,WBS element ,network and activity using a BDC program,
I am able to create to a recording for the transaction cj20n using tcode shdb but when i run the recording it doesnt run properly i am not able to create any thing.
I get error saying that a particular field doesnt exist on the screen.
Is possible to create a BDC program for transaction CJ20N ?
Also is there any other alternative apart from using a BAPI or a function module.
Thanks,
NishantHi,
Check below link for BAPIs of transaction cj20n.
[BAPI for cj20n|BAPI for CJ20N transaction]
Thanks,
Asit Purbey. -
Please Help me How write the BDC program for the MIGO inbound Delivery
Please help me how to write bdc program for the MIGO Inbound Delivery in 4.7EE Version. Please help me.
Not in LSMW. Required call transaction or Session Method. Please help me.
MohanRun transaction BAPI . Select Logistics Execution/Shipping/InboundDelivery/SaveReplica.. You can use function module BAPI_INB_DELIVERY_SAVEREPLICA in your ABAP program.
-
Error in BDC program for Block vendor in SAP R/3
Hello friends,
I wrote a BDC program to block vendor using FK02.
When I debug the program in <b>No screen</b> mode
the program gives a error 'No batch input data for screen SAPMSSY3 0131.
But the screen name and screen number is not available in the program.
When I execute without debugging in No screen mode, the program works correctly.
When I run in ALL screen mode, the program works correctly and the program does not prompt for SAPMSSY3 0131 screen.
Is there any solution for this problem.check this
... MODE mode
Effect
The processing mode can take the following values:
'A' Display screen
'E' Display only if an error occurs
'N' Do not display
<b>'P' Do not display; debugging possible</b>
If the MODE addition is omitted, then the processing mode is 'A'.
If a screen is displayed in processing mode 'E' because the system reached the end of the BDC data, the system automatically switches to processing mode 'A'.
If breakpoints are set in a transaction tcod called using the CALL TRANSACTION tcod USING itab variant, these are not actually reached in 'N' mode. The system tries to insert data in the Debugger screen; the call ends with SY-SUBRC = 1001 and the message "Batch input data is not available for screen SAPMSSY3 0131" (S 00 344).
Conversely, in 'P' mode, transaction screens are processed in the background (as in 'N' mode) and debugging is possible.
Regards
Prabhu -
How to create a BDC program for given recording.
i have to create a BDC program for uploading a file.
currently i am using call function
CALL FUNCTION 'F4_FILENAME'just check out the code below it is for updating two transactions
types Declaration *
types: begin of t_tab1 ,
vendor(10),
material(18),
pur_org(4),
wglif(18),
end of t_tab1.
Data Declaration *
data : begin of it_tab5 occurs 0,
vendor(10),
material(18),
end of it_tab5.
**DATA : BEGIN OF IT_TAB6 OCCURS 0,
VENDOR(10),
MATERIAL(18),
END OF IT_TAB6.
data: it_tab1 type standard table of t_tab1 with header line.
data: wa_tab1 type t_tab1.
data: wa_tab2 type t_tab1.
data: it_tab3 like bdcdata occurs 0 with header line.
data: it_tab4 like bdcdata occurs 0 with header line.
data: it_tab2 type table of bdcmsgcoll with header line.
data: d_file_name like ibipparms-path,
d_file_name1 type string.
Start-of-selection *
start-of-selection.
FM for finding the flat file
call function 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
importing
file_name = d_file_name.
d_file_name1 = d_file_name.
******FM for uploading data from flat file into internal table
call function 'GUI_UPLOAD'
exporting
filename = d_file_name1
filetype = 'ASC'
HAS_FIELD_SEPARATOR = ' '
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
IMPORTING
FILELENGTH =
HEADER =
tables
data_tab = it_tab5
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.
End-of-selection *
end-of-selection.
sort it_tab5 by vendor.
loop at it_tab5.
perform bdc_dynpro using 'SAPLBG00' 0101 .
perform bdc_field using 'BDC_OKCODE' '/00' .
perform bdc_dynpro using 'SAPLBG00' 1000 .
perform bdc_field using 'BDC_OKCODE' '=BUCH' .
perform bdc_field using 'BDC_SUBSCR'
'SAPLBG00 1101KOPF_1000'.
perform bdc_field using 'GBGMK-GAART' '2' .
perform bdc_field using 'GBGMK-GAERB' 'X' .
perform bdc_field using 'BDC_SUBSCR'
'SAPLBG00 1103TAB_SUB_1000'.
perform bdc_field using 'BDC_CURSOR' 'GBGMP-LSTNR(01)' .
perform bdc_field using 'GBGMP-LSTNR(01)' it_tab5-material .
call transaction 'BGM1' using it_tab3 mode 'E' messages into it_tab2
refresh it_tab3.
wa_tab1-pur_org = 'ABCP'.
loop at it_tab2.
endloop.
perform bdc_dynpro using 'SAPMM06I' 0100 .
perform bdc_field using 'BDC_CURSOR' 'EINE-EKORG' .
perform bdc_field using 'BDC_OKCODE' '/00' .
perform bdc_field using 'EINA-LIFNR' it_tab5-vendor .
perform bdc_field using 'EINA-MATNR' it_tab5-material .
perform bdc_field using 'EINE-EKORG' wa_tab1-pur_org .
perform bdc_field using 'RM06I-NORMB' 'X' .
perform bdc_dynpro using 'SAPMM06I' 0101 .
perform bdc_field using 'BDC_CURSOR' 'EINA-WGLIF' .
perform bdc_field using 'BDC_OKCODE' '=BU' .
perform bdc_field using 'EINA-WGLIF' it_tab2-msgv1 .
call transaction 'ME12' using it_tab3 mode 'E'.
refresh it_tab3.
refresh it_tab2.
endloop.
*& Form BDC_DYNPRO
Start new screen
-->P_FNAM text
-->P_FVAL text
form bdc_dynpro using program
dynpro.
clear it_tab3.
it_tab3-program = program.
it_tab3-dynpro = dynpro.
it_tab3-dynbegin = 'X'.
append it_tab3.
endform. " BDC_DYNPRO
*& Form BDC_FIELD
Insert field
-->P_FNAM text
-->P_FVAL text
form bdc_field using fnam
fval.
clear it_tab3.
it_tab3-fnam = fnam.
it_tab3-fval = fval.
append it_tab3.
endform. " BDC_FIELD
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Apr 14, 2008 6:20 PM -
Hi Experts,
h3 We need a BDC for MMRV program.
1) The requirement is that we should be able to run this as a batch job with a Z transaction & the selection screen parameters should be a range of Company codes (MARV-BUKRS).
2) The batch job should remove the flag ;Allow posting to previous period;(MARV-XRUEM) for this range of company codes entered in the selection screen.
3) Currently we can enter only one company code in the standard MMRV transaction
4) But we want to be able to enter a range of company codes.
Can any one please suggest me whether it is possible or not. if possible how we can give ranges for company code in BDC.
Thanks in advance,
DhanuHi,
Yes it is perfectly pssible. First make it work for one company code. Then repeat the same process for the next company code captured in selection screen say s_bukrs. Repeat this process till you are thr'u with all company codes from s_bukrs.
I hope this helps,
Regards
Raju Chitale -
If your Team Lead given Functional Specifications for a BDC program and you
If your Team Lead given Functional Specifications for a BDC program and you need to decide wether to write a Method Call Transaction or a Session.
How you will decide ?Hi Krishna,
See this you will got some ideas.
Diff b/w call transaction and session method is
Call transaction.
1) asynchronous processing
2) can transfer small amount of data
3) processing is faster.
4) errors need to be handled explicitly
5) data is updated automatically
Session method.
1) synchronous processing.
2) can tranfer large amount of data.
3) processing is slower.
4) error log is created
5) data is not updated until session is processed.
Thanks,
Reward If Helpful. -
You are given functional specs for a BDC program
You are given functional specs for a BDC program
and you need to decide whether to write a method
call transaction or a session. How u will decide?
plz explain clearlydepends of type of erro handling required and amount of data to be transfered, we can decide which is best method.
call transaction - no errorhandling, we have to write a code to show errors
sessin method - errohandling is there, locking mechanism is there.
for large amount of data , we should go for session method. for faster data transfer we can go for call transaction
Maybe you are looking for
-
i am runing ox10.4.11 and i will to upgrade to ox 10.5.11 anyone know where can i find the program!
-
Did you downloaded an app from the Ovi Store, erased it somehow and now it doesn't allow you to download again? Well, here is how you solve your problem: -Go to Menu -Select Settings -Select administration settings -Select installed applications -Sel
-
Artist list not showing all tracks by same (iOS 5.01)
Hi For some reason, I cannot see all the tracks by a particular artist when I select the "Artist" view. When browsing through the list of songs, or albums, or playsists, the tracks appear, listed with the correct (exact) artist name. Similarly, I hav
-
now i am creating BAPI for deleting purchase orders using bapi_po_change. help me in this.tell me how to start this.which bisiness object i have to use.its urgent.plz.
-
Hi, I was wondering if anyone has found a "test site" that would allow me to try out a course in a simulated LMS. My goal is to try my courses out on an LMS before passing it along to my client for installation on their LMS. I have been using the S