Select Accounting View in BDC Program
Hi Experts,
I am working on a BDC program in which I have to change the Accounting view data for Materials(MM02).
Each material has diferent number of views. So How can I select only the Accounting View when changing Material data through BDC.
Thanks
Kumar
Hi ashok ,
ideally you should use BAPI_Material_savedata to change the material master.
as far as your problem goes you can use the following method to select appropraite view in MM02.
SET PARAMETER ID 'MXX' FIELD c_v.
c_v is a char 1 constant and can have values
User department Maintenance statu(Value of c_v)
Work scheduling A
Accounting B
Classification C
MRP D
Purchasing E
Production resources/tools F
Costing G
Basic data K
Storage L
Forecasting P
Quality management Q
Warehouse management S
Sales V
Plant stocks X
Storage location stocks Z
Regards,
N.
Edited by: navjot sharma on May 26, 2008 2:02 PM
Similar Messages
-
Issue with BDC program used for FBZ5 (Check Print)
Hi all,
I am having one requirement in Check printing. as per that i have made one Z program which will accept multiple Payment documents. I am passing selected accounting documents to BDC routine for Transaction FBZ5. (As in FBZ5 we can take a print for one Payment document not for multiple)
We can have 3 scenarios in FBZ5
1. Fresh Check printing (First time check printing)
2. Old Check (printing for same Check no)
3. New Check (After voiding older check)
Category 1 and 2 are working fine but i am facing problem in category 3.
For Category 3 : BDC Screen flow is like this
A. Tcode FBZ5 Start program: SAPMFCHK Screen: 750 --> Click on 'Print'
B. Program: SAPLSPO2 Screen: 0100 --> Here specify option 'New Check'
C. Program: SAPMFCHK Screen: 0700
- This program belongs to new Tcode FCH7
- Here we have to give Void Reason code
Now issue with Category 3:
While executing BDC in online and background mode my control is terminating at step C mentioned above
Troubleshooting:
I have debugged standard program of FBZ5
1. in Include MFCHKFD0 we can see call to Tcode FCH7 (PERFORM AUFRUF_FCH7.)
2. in form AUFRUF_FCH7 i found code related to BDC
also there one statement is getting triggered --> CALL TRANSACTION 'FCH7' USING BDC MODE 'A'.
So there is a BDC call inside my Z BDC program, so is this a reason why my program is not working for above scenario ?
Or can't we handle above scenario in a way mentioned above?Hi Sandra,
I was trying to upload customer master in fd01 using bdc. The screens were different while recording. So could not perform the upload. Thenone screen was skipped so that the bdc was working fine and the data was uploaded.
This is the flow of the recording.
'SAPMF02D' '0105'.
SAPMF02D' '7105'
SAPMF02D' '0111
SAPMF02D' '0120
SAPMF02D' '0130
SAPMF02D' '0210
SAPMF02D' '0215
SAPMF02D' '0220'
SAPMF02D' '0230'
SAPMF02D' '0610
After the second screen was deleted the bdc worked fine. -
Selection view in MM02 BDC program
Hi Experts,
I am doing BDC Session method for Tcode MM02.There i am getting selection View screen for different material.But if i select a material in Sales view i need to select Sales :Sales org dAta.
It's coming third position.
But for some material it's coming fourth view.
If i record bdc in third position it'll take third view some other. how i can select the view in selection view.
Please,Anybody knows give me the suggestion.
Thanks & Regards,
NandhaHi,
use this Function module <b>SELECTION_VIEWS_FIND</b> to find the view position.
This One of functional modules for those who still has to use BDC for Material Master transactions (MM01 and MM02). Allows to determine line number for desired view in the "Select View(s)" window, to prepare BDC for the view access
Find the positon of the View based on this function module and write the code to select that perticular view.
Hope this solves your problem
Thanks
Sudheer -
Hi to all
I'm new to BDC Progaram
can u tell me how to write a
BDC program to upload purchase order data from legacy system.Hi Viswanath,
First i will explain the procedure step by step and will send a sample code plz check it once ok..And also i will attach a flat file at the end of SAMPLE CODE CHECK IT ONCE OK..
Steps:
1.Bulid an internal table first according to ur flat file fields.
2.select the flat file by using PARAMETER.
3.And assign that file path to GUI_UPLOAD function module.
4.Call BDC_OPEN_GROUP is used to open the session.
5.loop that flat file data and palce BDC_INSERT funtion module in that loop for uploading data into database table
6.After loop call BDC_CLOSE_GROUP to close the session.
SAMPLE CODE:
REPORT ybdc_session_mm01 NO STANDARD PAGE HEADING LINE-SIZE 255.
Global Structure for BDC Data
DATA: it_bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
Internal Table
DATA: BEGIN OF itab OCCURS 0,
mbrsh LIKE rmmg1-mbrsh,
mtart LIKE rmmg1-mtart,
maktx LIKE makt-maktx,
meins LIKE mara-meins,
END OF itab.
Upload the flat file
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename =
'C:\Documents and Settings\Compaq_Owner\Desktop\satish\mm01.txt'
filetype = 'ASC'
has_field_separator = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
data_tab = itab.
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Session Method Starts
BDC_OPEN_GROUP
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
DEST = FILLER8
GROUP = 'ychinnu'
HOLDDATE = FILLER8
KEEP = 'X'
USER = SY-UNAME
RECORD = FILLER1
PROG = SY-CPROG
IMPORTING
QID =
EXCEPTIONS
CLIENT_INVALID = 1
DESTINATION_INVALID = 2
GROUP_INVALID = 3
GROUP_IS_LOCKED = 4
HOLDDATE_INVALID = 5
INTERNAL_ERROR = 6
QUEUE_ERROR = 7
RUNNING = 8
SYSTEM_LOCK_ERROR = 9
USER_INVALID = 10
OTHERS = 11
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Create BDCDATA Structure
*include bdcrecx1.
START-OF-SELECTION.
PERFORM open_group.
loop at itab.
PERFORM bdc_dynpro USING 'SAPLMGMM' '0060'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RMMG1-MTART'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'RMMG1-MBRSH'
itab-mbrsh.
PERFORM bdc_field USING 'RMMG1-MTART'
itab-mtart.
After enterning MBRSH,MTART we press enter
PERFORM bdc_dynpro USING 'SAPLMGMM' '0070'. "press Enter
PERFORM bdc_field USING 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
View selection (Basic data1)
PERFORM bdc_field USING 'MSICHTAUSW-KZSEL(01)'"view selection
'X'.
Select Tick Mark (ok)
PERFORM bdc_dynpro USING 'SAPLMGMM' '4004'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BU'.
PERFORM bdc_field USING 'MAKT-MAKTX'
itab-maktx.
PERFORM bdc_field USING 'BDC_CURSOR'
'MARA-MEINS'.
PERFORM bdc_field USING 'MARA-MEINS'
itab-meins.
Finally after filling the data we save the data.
PERFORM bdc_field USING 'MARA-MTPOS_MARA' "For saving
'NORM'.
PERFORM bdc_transaction USING 'MM01'.
PERFORM close_group.
BDC_INSERT
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'MM01'
POST_LOCAL = NOVBLOCAL
PRINTING = NOPRINT
SIMUBATCH = ' '
CTUPARAMS = ' '
TABLES
dynprotab = it_bdcdata
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN = 2
QUEUE_ERROR = 3
TCODE_INVALID = 4
PRINTING_INVALID = 5
POSTING_INVALID = 6
OTHERS = 7
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Refresh BDCDATA
refresh it_bdcdata.
endloop.
Closing BDC Group
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Start new screen *
FORM bdc_dynpro USING program dynpro.
CLEAR it_bdcdata.
it_bdcdata-program = program.
it_bdcdata-dynpro = dynpro.
it_bdcdata-dynbegin = 'X'.
APPEND it_bdcdata.
ENDFORM. "BDC_DYNPRO
Insert field *
FORM bdc_field USING fnam fval.
IF FVAL NODATA.
CLEAR it_bdcdata.
it_bdcdata-fnam = fnam.
it_bdcdata-fval = fval.
APPEND it_bdcdata.
ENDIF.
ENDFORM. "BDC_FIELD
Flat File
*M FERT IRON KG
*M ROH STEEL KG
*M HALB IRON KG
Award points if helpful.
Kiran Kumar.G.A -
Hi ,
i have written a bdc program for f-02 .here we have 2 posting keys 31 and 40 .when i recored in shdb i can see when i use 31 posting key then i get 302 screen and when i use 40 posting key then i get 300 screen.But the problem is in 302 screen we have new posting keys and new account numbers .how to update these . here is my code . my file is not getting updated when i get screen 302 .Any advice?
REPORT zfip0009 NO STANDARD PAGE HEADING.
TABLES ska1.
DATA: BEGIN OF bdcdata OCCURS 0.
INCLUDE STRUCTURE bdcdata.
DATA: END OF bdcdata.
DATA w_date(10) TYPE c.
DATA w_first TYPE c.
DATA w_second TYPE c.
data from flat file
DATA: BEGIN OF t_data OCCURS 0,
bukrs LIKE bkpf-bukrs, "company code
newbs LIKE rf05a-newbs, "Posting Key
newko LIKE rf05a-newko, "New account number(SAP)
wrbtr(13) TYPE c, "amount
dmbtr(13) TYPE c, "sterling local amount "+MW1
mwskz LIKE bseg-mwskz, "Tax code
sgtxt LIKE bseg-sgtxt, "item description
kostl LIKE cobl-kostl, "Cost centre
ps_posid LIKE cobl-ps_posid, "WBS number
aufnr LIKE cobl-aufnr, "Internal order
END OF t_data.
SELECTION SCREEN
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_file LIKE rlgrap-filename
DEFAULT 'C:\temp\XSL.txt'.
SELECTION-SCREEN SKIP.
PARAMETERS: p_sess(12) DEFAULT 'GLPOSTING'.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS: p_bldat LIKE bkpf-bldat,
p_budat LIKE bkpf-budat,
p_blart LIKE bkpf-blart,
p_monat LIKE bkpf-monat,
p_bukrs LIKE bkpf-bukrs,
p_bktxt LIKE bkpf-bktxt,
p_xblnr LIKE bkpf-xblnr,
p_waers LIKE bkpf-waers.
SELECTION-SCREEN END OF BLOCK b2.
*SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.
*PARAMETERS p_ktopl LIKE ska1-ktopl.
*SELECTION-SCREEN END OF BLOCK b3.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
def_filename = p_file
DEF_PATH = ' '
mask = ',.,..'
MODE = ' '
TITLE = ' '
IMPORTING
filename = p_file
RC =
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
START OF SELECTION
START-OF-SELECTION.
Get all of the information held on the spreadsheets.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
filename = p_file
filetype = 'DAT'
TABLES
data_tab = t_data
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
WRITE :/ 'Failed to Open Input file', p_file.
EXIT.
ENDIF.
REFRESH bdcdata.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
client = sy-mandt
group = p_sess
user = sy-uname
keep = 'X'.
PERFORM load_bdcdata.
CALL FUNCTION 'BDC_CLOSE_GROUP'.
WRITE: /
'Batch input session', p_sess, 'created: process session via SM35'.
END-OF-SELECTION.
*& Form LOAD_BDCDATA
Load the BDCDATA fields depending
FORM load_bdcdata.
CLEAR: w_first, w_second.
CLEAR bdcdata.
LOOP AT t_data.
IF sy-tabix = 1.
PERFORM bdc_dynpro USING 'SAPMF05A' '0100'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF05A-NEWKO'.
PERFORM format_date USING p_bldat.
PERFORM bdc_field USING 'BKPF-BLDAT'
w_date.
PERFORM bdc_field USING 'BKPF-BLART'
p_blart.
PERFORM bdc_field USING 'BKPF-BUKRS'
t_data-bukrs.
PERFORM format_date USING p_budat.
PERFORM bdc_field USING 'BKPF-BUDAT'
w_date.
PERFORM bdc_field USING 'BKPF-WAERS'
p_waers.
PERFORM bdc_field USING 'BKPF-MONAT'
PERFORM bdc_field USING 'BKPF-BKTXT'
p_bktxt.
PERFORM bdc_field USING 'BKPF-XBLNR'
p_xblnr.
PERFORM bdc_field USING 'RF05A-NEWBS'
t_data-newbs.
PERFORM bdc_field USING 'RF05A-NEWKO'
t_data-newko.
ELSE.
PERFORM bdc_dynpro USING 'SAPMF05A' '0300'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF05A-NEWKO'.
PERFORM bdc_field USING 'RF05A-NEWBS'
t_data-newbs.
PERFORM bdc_field USING 'RF05A-NEWKO'
t_data-newko.
PERFORM bdc_field USING 'RF05A-NEWBK'
t_data-bukrs.
PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.
PERFORM bdc_field USING 'BDC_OKCODE' 'ENTE'.
ENDIF.
IF t_data-newbs = '31' .
w_second = '1'.
PERFORM bdc_dynpro USING 'SAPMF05A' '0302'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BDC_CURSOR'
'BSEG-SGTXT'.
PERFORM bdc_field USING 'BSEG-WRBTR'
t_data-wrbtr.
PERFORM bdc_field USING 'BSEG-SGTXT'
t_data-sgtxt.
PERFORM bdc_field USING 'RF05A-NEWBS'
t_data-newbs.
PERFORM bdc_field USING 'RF05A-NEWKO'
t_data-newko.
IF NOT t_data-kostl IS INITIAL.
PERFORM bdc_field USING 'COBL-KOSTL'
t_data-kostl.
ELSEIF NOT t_data-ps_posid IS INITIAL.
PERFORM bdc_field USING 'COBL-PS_POSID'
t_data-ps_posid.
ELSEIF NOT t_data-aufnr IS INITIAL.
PERFORM bdc_field USING 'COBL-AUFNR'
t_data-aufnr.
ENDIF.
*...start of Amendment MW1
IF p_waers ne 'GBP'.
PERFORM bdc_field USING 'BSEG-DMBTR'
t_data-dmbtr.
ENDIF.
ENDIF.
*...end of Amendment MW1 ENDIF.
IF t_data-newbs = '40' .
PERFORM bdc_dynpro USING 'SAPMF05A' '0300'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BDC_CURSOR'
'BSEG-SGTXT'.
PERFORM bdc_field USING 'BSEG-WRBTR'
t_data-wrbtr.
PERFORM bdc_field USING 'BSEG-SGTXT'
t_data-sgtxt.
PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.
PERFORM bdc_field USING 'BDC_OKCODE' 'ENTE'.
IF NOT t_data-kostl IS INITIAL.
PERFORM bdc_field USING 'COBL-KOSTL'
t_data-kostl.
ELSEIF NOT t_data-ps_posid IS INITIAL.
PERFORM bdc_field USING 'COBL-PS_POSID'
t_data-ps_posid.
ELSEIF NOT t_data-aufnr IS INITIAL.
PERFORM bdc_field USING 'COBL-AUFNR'
t_data-aufnr.
ENDIF.
PERFORM bdc_field USING 'BSEG-MWSKZ'
t_data-mwskz.
*...start of Amendment MW1
IF p_waers ne 'GBP'.
PERFORM bdc_field USING 'BSEG-DMBTR'
t_data-dmbtr.
ENDIF.
*...end of Amendment MW1
ENDIF.
AT FIRST.
calculate the tax
PERFORM bdc_field USING 'BKPF-XMWST' 'X'.
ENDAT.
IF t_data-newbs = '40' .
PERFORM bdc_field USING 'DKACB-FMORE'
'X'.
PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.
PERFORM bdc_field USING 'BDC_OKCODE'
'ENTE'.
IF NOT t_data-kostl IS INITIAL.
PERFORM bdc_field USING 'COBL-KOSTL'
t_data-kostl.
ELSEIF NOT t_data-ps_posid IS INITIAL.
PERFORM bdc_field USING 'COBL-PS_POSID'
t_data-ps_posid.
ELSEIF NOT t_data-aufnr IS INITIAL.
PERFORM bdc_field USING 'COBL-AUFNR'
t_data-aufnr.
ENDIF.
ENDIF.
ENDLOOP.
IF w_second = '1'.
PERFORM bdc_dynpro USING 'SAPMF05A' '0302'.
ELSE.
PERFORM bdc_dynpro USING 'SAPMF05A' '0300'.
ENDIF.
PERFORM bdc_field USING 'BDC_OKCODE'
'BU'.
PERFORM bdc_field USING 'BDC_CURSOR'
'BSEG-WRBTR'.
PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.
PERFORM bdc_field USING 'BDC_OKCODE'
'ENTE'.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
tcode = 'F-02'
TABLES
dynprotab = bdcdata.
REFRESH bdcdata.
CLEAR bdcdata.
ENDFORM. " LOAD_BDCDATA
Start of screen
FORM bdc_dynpro USING program dynpro.
CLEAR bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
APPEND bdcdata.
ENDFORM. "BDC_DYNPRO
insert field
FORM bdc_field USING fnam fval.
CLEAR bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
APPEND bdcdata.
ENDFORM. "BDC_FIELD
*& Form format_date
text
FORM format_date USING p_date.
CLEAR w_date.
w_date(2) = p_date+6(2).
w_date+2(1) = '.'.
w_date3(2) = p_date4(2).
w_date+5(1) = '.'.
w_date+6(4) = p_date(4).
ENDFORM. " format_dateIF item-newbs = '09'
OR item-newbs = '19'
OR item-newbs = '29'
OR item-newbs = '39'.
IF item-newum = 'A' OR
item-newum = 'V' OR
item-newum = '1' OR
item-newum = '2' OR
item-newum = '3' OR
item-newum = '5' OR
item-newum = '6' OR
item-newum = 'B' .
PERFORM bdc_dynpro USING 'SAPMF05A' '0304'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF05A-NEWUM'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BSEG-WRBTR'
item-wrbtr.
PERFORM bdc_field USING 'BSEG-gsber'
item-gsber.
PERFORM bdc_field USING 'BSEG-PRCTR'
item-prctr.
PERFORM bdc_field USING 'BSEG-ZFBDT'
item-zfbdt1.
PERFORM bdc_field USING 'BSEG-ZUONR'
item-zuonr.
PERFORM bdc_field USING 'BSEG-SGTXT'
item-sgtxt.
IF idx1 = '002' .
EXIT.
ENDIF.
idx = idx + 1.
READ TABLE item INDEX idx .
PERFORM bdc_field USING 'RF05A-NEWBS'
item-newbs.
PERFORM bdc_field USING 'RF05A-NEWKO'
item-newko.
PERFORM bdc_field USING 'RF05A-NEWUM'
item-newum.
PERFORM bdc_field USING 'RF05A-NEWBW'
item-newbw.
CONTINUE.
ENDIF.
ENDIF.
IF item-newbs = '09'
OR item-newbs = '19'
OR item-newbs = '29'
OR item-newbs = '39' .
IF item-newum = 'H'
OR item-newum = '4'
OR item-newum = '6'
OR item-newum = '7'
OR item-newum = '8'
OR item-newum = '9'
OR item-newum = 'C'
OR item-newum = 'D'
OR item-newum = 'E'
OR item-newum = 'I'
OR item-newum = 'K'
OR item-newum = 'L'
OR item-newum = 'M'
OR item-newum = 'O'
OR item-newum = 'Q'
OR item-newum = 'R'
OR item-newum = 'T'
OR item-newum = 'U'.
PERFORM bdc_dynpro USING 'SAPMF05A' '0303'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF05A-NEWKO'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BSEG-WRBTR'
item-wrbtr.
PERFORM bdc_field USING 'BSEG-GSBER'
item-gsber.
PERFORM bdc_field USING 'BSEG-ZFBDT'
item-zfbdt1.
PERFORM bdc_field USING 'BSEG-ZUONR'
item-zuonr.
PERFORM bdc_field USING 'BSEG-SGTXT'
item-sgtxt.
IF idx1 = '002' .
EXIT.
ENDIF.
idx = idx + 1 .
READ TABLE item INDEX idx .
PERFORM bdc_field USING 'RF05A-NEWBS'
item-newbs.
PERFORM bdc_field USING 'RF05A-NEWKO'
item-newko.
PERFORM bdc_field USING 'RF05A-NEWUM'
item-newum.
PERFORM bdc_field USING 'RF05A-NEWBW'
item-newbw.
CONTINUE.
ENDIF.
ENDIF.
IF item-newbs = '29' OR item-newbs = '39'.
IF item-newum = '7'.
PERFORM bdc_dynpro USING 'SAPMF05A' '0303'.
PERFORM bdc_field USING 'BDC_CURSOR'
'BSEG-ZFBDT'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ZK'.
PERFORM bdc_field USING 'BSEG-WRBTR'
item-wrbtr.
PERFORM bdc_field USING 'BSEG-GSBER'
item-gsber.
PERFORM bdc_field USING 'BSEG-ZFBDT'
item-zfbdt1.
PERFORM bdc_field USING 'BSEG-ZUONR'
item-zuonr.
PERFORM bdc_field USING 'BSEG-SGTXT'
item-sgtxt.
PERFORM bdc_dynpro USING 'SAPMF05A' '0332'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF05A-NEWKO'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BSEG-BEWAR'
item-ttype.
IF idx1 = '002' .
EXIT.
ENDIF.
idx = idx + 1 .
READ TABLE item INDEX idx .
PERFORM bdc_field USING 'RF05A-NEWBS'
item-newbs.
PERFORM bdc_field USING 'RF05A-NEWKO'
item-newko.
PERFORM bdc_field USING 'RF05A-NEWUM'
item-newum.
PERFORM bdc_field USING 'RF05A-NEWBW'
item-newbw.
CONTINUE.
ENDIF.
ENDIF.
IF item-newbs = '01' OR item-newbs = '11'
OR item-newbs = '05' OR item-newbs = '15'.
PERFORM bdc_dynpro USING 'SAPMF05A' '0301'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF05A-NEWKO'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BSEG-WRBTR'
item-wrbtr.
PERFORM bdc_field USING 'BSEG-GSBER'
item-gsber.
PERFORM bdc_field USING 'BSEG-ZTERM'
item-zterm.
PERFORM bdc_field USING 'BSEG-ZFBDT'
item-zfbdt.
PERFORM bdc_field USING 'BSEG-ZUONR'
item-zuonr.
PERFORM bdc_field USING 'BSEG-SGTXT'
item-sgtxt.
IF idx1 = '002' .
EXIT.
ENDIF.
idx = idx + 1 .
READ TABLE item INDEX idx .
PERFORM bdc_field USING 'RF05A-NEWBS'
item-newbs.
PERFORM bdc_field USING 'RF05A-NEWKO'
item-newko.
PERFORM bdc_field USING 'RF05A-NEWUM'
item-newum.
PERFORM bdc_field USING 'RF05A-NEWBW'
item-newbw.
CONTINUE.
ENDIF.
IF item-newbs = '21' OR item-newbs = '31'
OR item-newbs = '25' OR item-newbs = '35'.
PERFORM bdc_dynpro USING 'SAPMF05A' '0302'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF05A-NEWKO'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BSEG-WRBTR'
item-wrbtr.
PERFORM bdc_field USING 'BSEG-SECCO'
''. "'1000'.
PERFORM bdc_field USING 'BSEG-GSBER'
item-gsber.
PERFORM bdc_field USING 'BSEG-ZTERM'
item-zterm.
PERFORM bdc_field USING 'BSEG-ZFBDT'
item-zfbdt.
PERFORM bdc_field USING 'BSEG-ZUONR'
item-zuonr.
PERFORM bdc_field USING 'BSEG-SGTXT'
item-sgtxt.
IF idx1 = '002' .
EXIT.
ENDIF.
idx = idx + 1.
READ TABLE item INDEX idx.
PERFORM bdc_field USING 'RF05A-NEWBS'
item-newbs.
PERFORM bdc_field USING 'RF05A-NEWKO'
item-newko.
PERFORM bdc_field USING 'RF05A-NEWUM'
item-newum.
PERFORM bdc_field USING 'RF05A-NEWBW'
item-newbw.
CONTINUE.
ENDIF.
IF item-newbs = '70' OR item-newbs = '75'.
PERFORM bdc_dynpro USING 'SAPMF05A' '0305'.
PERFORM bdc_field USING 'BDC_CURSOR'
'BSEG-WRBTR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BSEG-WRBTR'
item-wrbtr.
PERFORM bdc_field USING 'DKACB-FMORE'
'X'.
PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.
PERFORM bdc_field USING 'BDC_CURSOR'
'COBL-PRCTR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTE'.
PERFORM bdc_field USING 'COBL-GSBER'
item-gsber.
PERFORM bdc_field USING 'COBL-KOSTL'
item-kostl.
PERFORM bdc_field USING 'COBL-PRCTR'
item-prctr.
PERFORM bdc_dynpro USING 'SAPMF05A' '0305'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF05A-NEWBW'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BSEG-WRBTR'
item-wrbtr.
PERFORM bdc_field USING 'BSEG-BZDAT'
'01.04.2005'.
IF idx1 = '002' .
EXIT.
ENDIF.
idx = idx + 1 .
READ TABLE item INDEX idx .
PERFORM bdc_field USING 'RF05A-NEWBS'
item-newbs.
PERFORM bdc_field USING 'RF05A-NEWKO'
item-newko.
PERFORM bdc_field USING 'RF05A-NEWUM'
item-newum.
PERFORM bdc_field USING 'RF05A-NEWBW'
item-newbw.
CONTINUE.
ENDIF.
ENDLOOP.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BU'.
PERFORM bdc_transaction USING 'F-02'.
DELETE item INDEX 1.
DELETE item INDEX 1.
ix = ix + 2 .
ENDDO.
PERFORM close_group. -
How to call a maintenance view from a program
Hello Abapers,
Can anybody explain with some examples. How to call a mainetenance view from a program.
Thanks
Ranjith.Use FM 'VIEW_MAINTENANCE_CALL'.
REPORT zmaintaintest.
VARIABLES / CONSTANTS
CONSTANTS:
c_action(1) TYPE c VALUE 'U', "Update
c_viewname TYPE tabname value 'ZEMP_EXAMPLE', "View Name
c_field(6) TYPE c VALUE 'EMPNO'. "Field Name
INTERNAL TABLES
DATA: itab_rangetab TYPE STANDARD TABLE OF vimsellist,
v_empno TYPE zempno,
wa_rangetab TYPE vimsellist.
SELECTION SCREEN
PARAMETERS: p_empno TYPE zempno OBLIGATORY. "Emplyee ID
AT SELECTION-SCREEN
AT SELECTION-SCREEN.
Chcking the existence of the user in EMPLOYEE table
PERFORM validate_employee.
START_OF_SELECTION
START-OF-SELECTION.
This will restrict the user view so that user can only view/change
Table data corresponding to his/her Employee ID
PERFORM define_limited_data_area.
Displaying table maintenance view for a particular employee ID
PERFORM call_view_maintenance.
*& Form validate_employee
Validate plant entered in the selection screen
FORM validate_employee.
SELECT SINGLE empno u201CEmployee ID
FROM zemp_example u201CEmployee Table
INTO v_empno
WHERE empno = p_empno.
IF sy-subrc <> 0.
MESSAGE 'Not an Valid User' TYPE 'I'.
ENDIF.
ENDFORM. "validate_employee
*& Form DEFINE_LIMITED_DATA_AREA
To restrict the user view so that user can see/change table data
corresponding to his employee ID. Here one internal table is
getting populated with field name as u201CEMPNOu201D (Key field of the table)
And value as given by user in Selection Screen and this is passed as
Parameter in function module 'VIEW_MAINTENANCE_CALL'
FORM define_limited_data_area.
CLEAR wa_rangetab.
wa_rangetab-viewfield = c_field.
wa_rangetab-operator = 'EQ'.
wa_rangetab-value = p_empno.
APPEND wa_rangetab TO itab_rangetab.
ENDFORM. "define_limited_data_area
*& Form CALL_VIEW_MAINTENANCE.
Displaying table maintenance view for a particular employee ID
FORM call_view_maintenance.
CALL FUNCTION 'VIEW_MAINTENANCE_CALL'
EXPORTING
action = c_action
view_name = c_viewname
TABLES
dba_sellist = itab_rangetab.
ENDFORM. "call_view_maintenance
Regards,
Joy. -
Changes in BDC program to upload data from text/excel file
Hi friends i have obtained the BDc program after recording :
start-of-selection.
perform open_group.
perform bdc_dynpro using 'SAPLCOIH' '0100'.
perform bdc_field using 'BDC_CURSOR'
'CAUFVD-GSBER'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'AUFPAR-PM_AUFART'
'PM01'.
perform bdc_field using 'CAUFVD-IWERK'
'460a'.
perform bdc_field using 'CAUFVD-GSBER'
'2460'.
perform bdc_field using 'CAUFVD-EQUNR'
'10000009'.
perform bdc_dynpro using 'SAPLCOIH' '3000'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'CAUFVD-KTEXT'
'abc'.
perform bdc_field using 'CAUFVD-INGPR'
'GM'.
perform bdc_field using 'CAUFVD-VAPLZ'
'RTN_VELR'.
perform bdc_field using 'CAUFVD-VAWRK'
'460A'.
perform bdc_field using 'BDC_CURSOR'
'CAUFVD-GLTRP'.
perform bdc_field using 'CAUFVD-GSTRP'
'1.8.2010'.
perform bdc_field using 'CAUFVD-GLTRP'
'1.8.2010'.
perform bdc_field using 'CAUFVD-TPLNR'
'RTNP-HIG'.
perform bdc_field using 'CAUFVD-EQUNR'
'10000009'.
perform bdc_field using 'AFVGD-INDET'
'1'.
perform bdc_field using 'AFVGD-WERKS'
'460A'.
perform bdc_field using 'AFVGD-STEUS'
'PMIN'.
perform bdc_field using 'AFVGD-ARBEH'
'H'.
perform bdc_field using 'AFVGD-DAUNE'
'H'.
perform bdc_dynpro using 'SAPLCOIH' '3000'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'BDC_CURSOR'
'CAUFVD-KTEXT'.
perform bdc_field using 'CAUFVD-KTEXT'
'abc'.
perform bdc_field using 'CAUFVD-INGPR'
'GM'.
perform bdc_field using 'CAUFVD-VAPLZ'
'RTN_VELR'.
perform bdc_field using 'CAUFVD-VAWRK'
'460A'.
perform bdc_field using 'CAUFVD-GSTRP'
'01.08.2010'.
perform bdc_field using 'CAUFVD-GLTRP'
'01.08.2010'.
perform bdc_field using 'CAUFVD-TPLNR'
'RTNP-HIG'.
perform bdc_field using 'CAUFVD-EQUNR'
'10000009'.
perform bdc_field using 'AFVGD-LTXA1'
'abc'.
perform bdc_field using 'AFVGD-INDET'
'1'.
perform bdc_field using 'AFVGD-ARBPL'
'RTN_VELR'.
perform bdc_field using 'AFVGD-WERKS'
'460A'.
perform bdc_field using 'AFVGD-STEUS'
'PMIN'.
perform bdc_field using 'AFVGD-ARBEH'
'H'.
perform bdc_field using 'AFVGD-DAUNE'
'H'.
perform bdc_transaction using 'IW31'.
perform close_group.
after executing it has two options.one is for call transactioin and other is for with session.Now i want to do the uploading from text file.Please guide me how to achieve that and what should be the order of fields in the text file.I am just a beginner.I know how to do that with LSMW bt trying BDc first time for creating PM ordersYou can use class "cl_gui_frontend_services". First you must select file with "file_open_dialog" method and the you can upload file with "gui_upload" method into internal table. Here is a sample: (I didn't try the code but I'm sure you can get it working, there are lots of sample codes about that. You can also search FM "GUI_UPLOAD").
REPORT zreport.
DATA:
gv_subrc TYPE sysubrc,
gv_result TYPE abap_bool,
gt_data_tab type table of zstruc.
PARAMETERS: p_fname LIKE rlgrap-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname.
PERFORM file_open_dialog USING space space space space
CHANGING p_fname gv_action gv_subrc.
START-OF-SELECTION.
PERFORM gui_upload TABLES gt_data_tab
USING p_fname CHANGING gv_subrc.
*** FORMS ***
FORM file_open_dialog USING pv_window_title
pv_default_extension
pv_default_filename
pv_initial_directory
CHANGING pv_filename
pv_user_action
pv_subrc.
DATA:
lt_file_table TYPE filetable,
lv_rc TYPE i,
lv_initial_directory TYPE string.
IF pv_initial_directory IS INITIAL.
PERFORM get_desktop_directory CHANGING lv_initial_directory.
ELSE.
lv_initial_directory = pv_initial_directory.
ENDIF.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = pv_window_title
default_extension = pv_default_extension
default_filename = pv_default_filename
* file_filter =
* with_encoding =
initial_directory = lv_initial_directory
* multiselection =
CHANGING
file_table = lt_file_table
rc = lv_rc
user_action = pv_user_action
* file_encoding =
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5
pv_subrc = sy-subrc.
IF pv_subrc EQ 0.
READ TABLE lt_file_table INTO pv_filename INDEX 1.
ENDIF.
ENDFORM.
FORM gui_upload TABLES pt_data_tab
USING pv_filename
CHANGING pv_subrc TYPE sysubrc.
DATA:
lt_data_tab TYPE TABLE OF string,
lv_filename TYPE string.
lv_filename = pv_filename.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = lv_filename
filetype = 'ASC'
has_field_separator = 'X'
* header_length = 0
* read_by_line = 'X'
* dat_mode = SPACE
* codepage = SPACE
* ignore_cerr = ABAP_TRUE
* replacement = '#'
* virus_scan_profile =
* show_transfer_status = 'X'
* IMPORTING
* filelength =
* header =
CHANGING
data_tab = lt_data_tab
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
not_supported_by_gui = 17
error_no_gui = 18
OTHERS = 19
pv_subrc = sy-subrc.
IF pv_subrc EQ 0.
pt_data_tab[] = lt_data_tab[].
ENDIF.
ENDFORM. -
Questions on BDC program statements.....
Hi,
Currently i am checking below BDC program for packing material use.
But there is a statement that i am not very clear what it is for...
PERFORM bdc_field USING 'BDC_CURSOR'
'V51VE-EXIDV(01)'.
For the 'V51VE-EXIDV(01)', here why need to add an (01) at the end. What does the (01) means??
Thanks!!!!
LOOP AT i_lips.
CLEAR: i_bdc_tab,i_msg_tab.
REFRESH: i_bdc_tab,i_msg_tab.
PERFORM bdc_dynpro USING 'SAPMV50A' '4004'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LIKP-VBELN'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'LIKP-VBELN'
i_lips-vbeln.
PERFORM bdc_dynpro USING 'SAPMV50A' '1000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=VERP_T'.
*perform bdc_field using 'LIKP-BLDAT'
* record-BLDAT_002.
PERFORM bdc_field USING 'BDC_CURSOR'
'LIPS-POSNR(01)'.
*perform bdc_field using 'LIKP-WADAT'
* record-WADAT_003.
*perform bdc_field using 'LIKP-WAUHR'
* record-WAUHR_004.
*perform bdc_field using 'LIKP-BTGEW'
* record-BTGEW_005.
*perform bdc_field using 'LIKP-GEWEI'
* record-GEWEI_006.
PERFORM bdc_dynpro USING 'SAPLV51G' '6000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
PERFORM bdc_field USING 'BDC_CURSOR'
'V51VE-VHILM(01)'.
PERFORM bdc_field USING 'V51VE-VHILM(01)'
'BOX'.
*Select all materails
PERFORM bdc_dynpro USING 'SAPLV51G' '6000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=HU_MARKA'.
*Select all Boxes
PERFORM bdc_dynpro USING 'SAPLV51G' '6000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=HUMARKHU'.
*perform bdc_field using 'V51VE-SELKZ(01)'
* record-SELKZ_01_008.
PERFORM bdc_dynpro USING 'SAPLV51G' '6000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=HU_VERP'.
PERFORM bdc_field USING 'BDC_CURSOR'
'V51VE-EXIDV(01)'.
PERFORM bdc_dynpro USING 'SAPLV51G' '6000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=SICH'.
PERFORM bdc_field USING 'BDC_CURSOR'
'V51VE-EXIDV(01)'.
CALL TRANSACTION 'VL02N' USING i_bdc_tab
MODE p_mode
MESSAGES INTO i_msg_tab.
Message was edited by:
Hoo LaaAnd if this is a BDC running in background, or a call transaction, then placing the cursor on a given field has no effect unless it is needed for navigation to the next screen.
When you record a BDC using SHDB there are a lot of statements like this that are added in but are not needed for the BDC to work.
Another example is the "BDC_SUBSCR" field name - this does not in most cases appear to have any effect on how the BDC is processed.
Also, the recording will include fields which have default values on the screen that you do not need to overwrite with the same value from the BDC.
I often delete these statements from the recording, taking care that I understand what the impact is. You can try commenting out the line and see what difference it makes to processing.
When using a BDC for updating a lot of records, having less of these types of lines in the BDCDATA table will speed performance a bit.
Andrew -
How do I add a Gmail account to my Mail program
Hi
Until now, I have only had @verizon.net email accounts. I now how a @gmail.com email account
I don't know how to configure my Mail program so I can receive gmail to my computer, and not have to get it using a Browser.
I have attended to configure, but it does not work: I get the following:
For Incomgin Mail Server I use:
mail.gmail.com
I get this response:
The POP server “mail.gmail.com” is not responding. Check your network connection and that you entered the correct information in the “Incoming Mail Server” field. If it still doesn’t respond, the server might be temporarily unavailable.First off Gmail supports "imap" which will allow you to keep your computer Mail app, and gmail account in sync. I would suggest you setting gmail up for imap instead of POP.
1. Open Mail go to preferences, select Accounts.
2. In the account window in the left pane "Accounts" press the "+" button at the bottom to add a new account.
3. An Account window will appear asking for information, select IMAP for account type, Description put what ever you wish such as "Gmail IMAP" or if you are going to have more that one accunt fro gmail the "User Gmail IMAP", Enter your Name, and your new Gmail address ex. "[email protected]".
4. Enter the information for incoming mail. In the incoming mail server box type: imap.gmail.com, Your user name should appear in the User Name box automatically if it is incorrect the correct it, enter your password that you use to access the mail from the web with gmail. Then press Continue.
If all the info is correct it will let you continue, as mail at that point actually goes out to that gmail server and attempts a login with that account and password, if it fails at this point then some info like your user name and password are incorrect. If it all goes well go to step 5.
5. The next screen will be the Outgoing mail, in the Outgoing mail server: box type: smtp.gmail.com, select authentication and put in your username and password for that account like you did on the prev step. Then press continue. Mail will again go out to that server and attempt a log in to very the information. If all goes well then mail will come back with an account summary window, you can then press continue.
That should do it, if it doesn't work post back. -
How can we pass the select-option value to modulepool program?
hi,
how can we pass the select-option value to modulepool program ?
Because if i declared select-options in executable program and i used SSCRFIELDS to define push buttons in selection screen.
My requirement if enter the values to select-options and press UPDATE pussbotton then i want call screen which contains tablecontrol.
How i get select-option values to PAI of call screen for getting the data from database table to my internal table?Oh I thought that you have selection-screen and again you are working on dialog programming.
if you want to use select-option directly in module pool then it is not possible.
but you can do other way.
create two varaiables
data : v_kun_low like kna1-kunnr,
v_kun_high like kna1-kunnr.
use these two variables in layout ,let user knows that he can not give options like gt,lt,eq ,it will be always BT.
and also when you see normal report program,you can use multiple values in either low or high,but here it is not possibel.
use can enter only low value and high value.
when you come to program point of view
declare one range
ranges r_kunnr for kna1-kunnr.
do the coding like
r_kunnr-low = v_kun_low.
r_kunnr-high = v_kun_high.
r_kunnr-options = 'BT'.
r_kunnr-sign = 'I'.
append r_kunnr.
now you can use r_kunnr in select query ,it will work like select-option.
other than this there is no option.
Thanks
Seshu -
How can we know the return code of BDC Program ?
Hi All,
Please tell me : How can we know the return code of BDC Program when being exceuted in Session or in Transaction mode.
In my program, we are uploading data from Excel sheet to SAP via BDC
The records that are not updated we want to create a log file.
Now to know whether a record is updated ot not, wat syst field shloud be used?
Its urgent....
<b>Reward Point will be there ....</b>
Thanks,
HarishHi harish,
try the logic in this code ...
i had attached input file in the end.
TYPES: begin of errmess,
msgnr type t100-msgnr,
text type t100-text,
end of errmess.
TABLES : t100.
DATA: BEGIN OF DD_VA01,
AUART TYPE VBAK-AUART,
KUNNR TYPE RV45A-KUNNR,
BSTKD TYPE VBKD-BSTKD,
MABNR TYPE RV45A-MABNR,
KWMENG(2) type C,
KBETR(2) type C,
END OF DD_VA01.
DATA:IT_VA01 Like TABLE OF DD_VA01,
WA_VA01 Like LINE OF IT_VA01,
WA_VA01_F Like LINE OF IT_VA01,
IT_BDCDATA TYPE TABLE OF BDCDATA,
WA_BDCDATA Like Line OF IT_BDCDATA,
W_FNAME TYPE STRING,
messtab like bdcmsgcoll occurs 0 with header line,
it_errmess type table of errmess,
wa_errmess like line of it_errmess,
err_message type string.
data: zf1 type i,
zc1 type c value '2',
fn(20) type c.
Main Code ************************************************************
PERFORM get_input using 'C:\Documents and Settings\ic881592\Desktop\Daran_bdc_VA01-e.txt'.
SORT IT_VA01 BY AUART KUNNR BSTKD.
LOOP AT IT_VA01 INTO WA_VA01.
if WA_VA01_F-AUART <> WA_VA01-AUART OR
WA_VA01_F-KUNNR <> WA_VA01-KUNNR OR
WA_VA01_F-BSTKD <> WA_VA01-BSTKD.
PERFORM set_header_flag.
PERFORM create_bdc_header_data.
endif.
PERFORM create_bdc_item_data.
ENDLOOP.
PERFORM call_transaction.
PERFORM errorlog.
Procedures ***********************************************************
form get_input using w_fname.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = W_FNAME
HAS_FIELD_SEPARATOR = '#'
TABLES
DATA_TAB = IT_VA01.
endform.
form call_transaction.
PERFORM bdc_field using 'BDC_OKCODE' '/11'.
CALL TRANSACTION 'VA01' USING IT_BDCDATA MODE 'A' messages into messtab.
refresh it_bdcdata.
endform.
FORM set_header_flag.
WA_VA01_F-AUART = WA_VA01-AUART.
WA_VA01_F-KUNNR = WA_VA01-KUNNR.
WA_VA01_F-BSTKD = WA_VA01-BSTKD.
if zf1 = 1.
PERFORM call_transaction.
endif.
zf1 = 1.
endform. "set_header_flag.
form create_bdc_header_data.
perform bdc_dynpro using 'SAPMV45A' '0101'.
perform bdc_field using 'VBAK-AUART' WA_VA01-AUART.
perform bdc_field using 'BDC_OKCODE' '/00'.
perform bdc_dynpro using 'SAPMV45A' '4001'.
perform bdc_field using 'KUAGV-KUNNR' WA_VA01-KUNNR.
perform bdc_field using 'VBKD-BSTKD' WA_VA01-BSTKD.
perform bdc_field using 'BDC_OKCODE' '/00'.
perform bdc_dynpro using 'SAPMSSY0' '0120'.
perform bdc_field using 'BDC_CURSOR' '04/06'.
perform bdc_field using 'BDC_OKCODE' '=CHOO'.
perform bdc_dynpro using 'SAPMV45A' '4001'.
PERFORM bdc_field USING 'BDC_OKCODE' '=POAN'.
endform. "create_bdcdata
FORM create_bdc_item_data.
CONCATENATE 'RV45A-KWMENG(' zc1 ')' INTO FN.
perform bdc_field using 'BDC_CURSOR' FN.
perform bdc_field using FN WA_VA01-KWMENG.
CONCATENATE 'KOMV-KBETR(' zc1 ')' INTO FN.
perform bdc_field using FN WA_VA01-KBETR.
CONCATENATE 'RV45A-MABNR(' zc1 ')' INTO FN.
perform bdc_field using FN WA_VA01-MABNR.
perform bdc_dynpro using 'SAPMV45A' '4001'.
PERFORM bdc_field USING 'BDC_OKCODE' '=POAN'.
ENDFORM.
form errorlog.
LOOP AT MESSTAB .
if MESSTAB-MSGNR = '311' or MESSTAB-MSGTYP = 'E'.
SELECT SINGLE msgnr text FROM T100
into wa_errmess
WHERE SPRSL = MESSTAB-MSGSPRA
AND ARBGB = MESSTAB-MSGID
AND MSGNR = MESSTAB-MSGNR.
IF SY-SUBRC = 0.
err_message = wa_errmess-TEXT.
IF err_message CS '&1'.
REPLACE '&1' WITH MESSTAB-MSGV1 INTO err_message.
REPLACE '&2' WITH MESSTAB-MSGV2 INTO err_message.
REPLACE '&3' WITH MESSTAB-MSGV3 INTO err_message.
REPLACE '&4' WITH MESSTAB-MSGV4 INTO err_message.
ELSE.
REPLACE '&' WITH MESSTAB-MSGV1 INTO err_message.
REPLACE '&' WITH MESSTAB-MSGV2 INTO err_message.
REPLACE '&' WITH MESSTAB-MSGV3 INTO err_message.
REPLACE '&' WITH MESSTAB-MSGV4 INTO err_message.
ENDIF.
CONDENSE err_message.
WRITE: / MESSTAB-MSGTYP, err_message .
ELSE.
WRITE: / MESSTAB.
ENDIF.
endif.
ENDLOOP.
endform. "errorlog
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
WA_BDCDATA-PROGRAM = PROGRAM.
WA_BDCDATA-DYNPRO = DYNPRO.
WA_BDCDATA-DYNBEGIN = 'X'.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
ENDFORM.
FORM BDC_FIELD USING FNAM FVAL.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
ENDFORM.
input file :
OR 2148 0001235 R-1162 8 17
OR 2148 0001235 R-1161 2 30
OR 2148 0001235 100-400 6 25
OR 2148 0001235 R-1162 4 12
OR 2148 0001236 R-1162 3 12
OR 2148 0001236 R-1161 2 30
OR 2148 0001236 100-400 1 25
OR 2148 0001236 R-1162 7 12
OR 2148 0001236 R-1161 8 30
OR 2148 0001236 100-400 10 25
OR 2148 0001235 R-1161 5 30
OR 2148 0001235 100-400 2 25
OR 2148 0001235 R-11621 3 12
OR 2148 0001235 R-1161 2 30
OR 2148 0001235 100-400 1 25
OR 2148 0001235 R-1162 7 12
OR 2148 0001235 R-1161 8 30
OR 2148 0001235 100-400 10 25
OR 2148 0001236 R-1162 8 17
OR 2148 0001236 R-1161 2 30
OR 2148 0001236 100-400 6 25
OR 2148 0001236 R-1162 4 12
OR 2148 0001236 R-1161 5 30
OR 2148 0001236 100-400 2 25 -
How to select plant view in BAPI_MATERIAL_SAVEDATA
Hi Friends,
I am using standard BAPI (BAPI_MATERIAL_SAVEDATA) to create Material Master. There is no option to select plant view in headdata itself but i need to populate plant data. So i've used PLANTDATA and PLANTDATAX parameter to pass plant name,storage location and period indicator.
say
PLANTDATA-plantname = '0011'.
PLANTDATA-storagelocation = '0011'.
PLANTDATA-periodind = 'D'.
PLANTDATAX-plantname = '0011'.
PLANTDATAX-storagelocation = 'X'.
PLANTDATAX-periodind = 'X'.
The material gets created but plant view is not created.
<<text removed>>
Thanks in advance.
Regards,
Prabhu
Edited by: Matt on May 5, 2009 11:15 AM - don't use ASAPHello,
Try this
Data:
PLANTDATA LIKE BAPI_MARC, "ins H 592229
PLANTDATAX LIKE BAPI_MARCX, "ins H 592229
Get plant
IF FT-FNAM = 'RM03M-WERKS'. "ins H 592229
PLANTDATA-PLANT = FT-FVAL. "ins H 592229
PLANTDATAX-PLANT = FT-FVAL. "ins H 592229
ENDIF.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA' "ins H 592229
EXPORTING "ins H 592229
HEADDATA = HEADDATA "ins H 592229
CLIENTDATA = CLIENTDATA "ins H 592229
CLIENTDATAX = CLIENTDATAX "ins H 592229
PLANTDATA = PLANTDATA "ins H 592229
PLANTDATAX = PLANTDATAX "ins H 592229
IMPORTING "ins H 592229
RETURN = RETURN_CODE2 "ins H 592229
TABLES "ins H 592229
MATERIALDESCRIPTION = MATERIALDESCRIPTION. "ins H 592229
Check this standard one is using in the same way
see this program MMCP3FP0 -
Problem in the BDC program to upload the data from a flat file.
Hi,
I am required to write a BDC program to upload the data from a flat file. The conditions are as mentioned below:-
1) Selection Screen will be prompted to user and user needs to provide:- File Path on presentation server (with F4 help for this obligatory parameter) and File Separator e.g. @,#,$,%,... etc(fields in the file will be separated by using this special character) or fields may be separated by tab(tab delimited).
2) Finally after the data is uploaded, following messages need to be displayed:-
a) Total Number of records successfully uploaded.
b) Session Name
c) Number of Sessions created.
Problem is when each record is fetched from flat file, the record needs to be split into individual fields separated by delimiter or in case tab separated, then proceeding in usual manner.
It would be great if you provide me either the logic, pseudocode, or sample code for this BDC program.
Thanks,Here is an example program, if you require the delimitor to be a TAB, then enter TAB on the selection screen, if you require the delimitor to be a comma, slash, pipe, whatever, then simply enter that value. This example is simply the uploading of the file, not the BDC, I assume that you know what to do once you have the data into the internal table.
REPORT zrich_0001.
TYPES: BEGIN OF ttab,
rec TYPE string,
END OF ttab.
TYPES: BEGIN OF tdat,
fld1(10) TYPE c,
fld2(10) TYPE c,
fld3(10) TYPE c,
fld4(10) TYPE c,
END OF tdat.
DATA: itab TYPE TABLE OF ttab.
data: xtab like line of itab.
DATA: idat TYPE TABLE OF tdat.
data: xdat like line of idat.
DATA: file_str TYPE string.
DATA: delimitor TYPE string.
PARAMETERS: p_file TYPE localfile.
PARAMETERS: p_del(5) TYPE c.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
DATA: ifiletab TYPE filetable.
DATA: xfiletab LIKE LINE OF ifiletab.
DATA: rc TYPE i.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
CHANGING
file_table = ifiletab
rc = rc.
READ TABLE ifiletab INTO xfiletab INDEX 1.
IF sy-subrc = 0.
p_file = xfiletab-filename.
ENDIF.
START-OF-SELECTION.
TRANSLATE p_del TO UPPER CASE.
CASE p_del.
WHEN 'TAB'.
delimitor = cl_abap_char_utilities=>horizontal_tab.
WHEN others.
delimitor = p_del.
ENDCASE.
file_str = p_file.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = file_str
CHANGING
data_tab = itab.
LOOP AT itab into xtab.
CLEAR xdat.
SPLIT xtab-rec AT delimitor INTO xdat-fld1
xdat-fld2
xdat-fld3
xdat-fld4.
APPEND xdat to idat.
ENDLOOP.
LOOP AT idat into xdat.
WRITE:/ xdat-fld1, xdat-fld2, xdat-fld3, xdat-fld4.
ENDLOOP.
Regards,
Rich Heilman -
BDC programming using Batch input Session.
Hello Experts.
I'm an ABAP beginner. I've benn practicing BDC programming using Batch input Session
at the moment.
This is the program that upload Local file which has plural records, and put the records into a Session.
These are the records.
413459,KIM EI HWAN121 ,19810607,MIADONG1234
423459,KIM EI HWAN122 ,19810607,MIADONG1235
433459,KIM EI HWAN123 ,19810607,MIADONG1236
443459,KIM EI HWAN124 ,19810607,MIADONG1237
453459,KIM EI HWAN125 ,19810607,MIADONG1238
463459,KIM EI HWAN126 ,19810607,MIADONG1239
I succeeded making Session.
However, for some reaseon, every record in the Session has got the same, value which is the first record.
Why is this happening? And How can I correct the code below?
REPORT ZBCUSER002_BATCH NO STANDARD PAGE HEADING
LINE-SIZE 255
MESSAGE-ID ZBATCH.
= Types definition ===================================================
TYPES: BEGIN OF TYP_LOCAL, "For Local file upload
RECORD(200) TYPE C,
END OF TYP_LOCAL.
= Internal table definition ==============================================
DATA: BEGIN OF BDC_TAB OCCURS 0. "BDCDATA itab
INCLUDE STRUCTURE BDCDATA.
DATA: END OF BDC_TAB.
DATA: BEGIN OF MESSAGE_BDC OCCURS 0. "Message itab
INCLUDE STRUCTURE BDCMSGCOLL.
DATA: END OF MESSAGE_BDC.
DATA: TBL_LOCAL TYPE STANDARD TABLE OF TYP_LOCAL, "Local file itab
F_TBL TYPE FILETABLE. "FILETABLE fot local
= Structure table definition =========================================
DATA: STR_F_TBL LIKE LINE OF F_TBL, "FILETABLE structure
STR_LOCAL TYPE TYP_LOCAL. "Local file structure
= Variable definition ================================================
DATA: LV_RC TYPE I, "Method parameter
ENUMBER TYPE ZT601-ENUMBER, "Employee number
NAME TYPE ZT601-NAME, "Employee name
BIRTH TYPE ZT601-BIRTH, "Birthday
HOMETOWN TYPE ZT601-HOMETOWN, "Hometown
SYSVAL TYPE SY-SUBRC. "System valuible
= Constants definition ===============================================
CONSTANTS: TBL_NAME(10) TYPE C VALUE 'ZT601'. "Table name ZT601
= Parameters definition ==============================================
PARAMETERS: F_NAME TYPE RLGRAP-FILENAME OBLIGATORY, "File path
EXECMODE(1) TYPE C. "Execute mode
INITIALIZATION
*----- Initialize all valuables, structures and internal tables
CLEAR: LV_RC,
STR_F_TBL,
STR_LOCAL,
ENUMBER,
NAME,
BIRTH,
HOMETOWN.
REFRESH: F_TBL,
TBL_LOCAL.
AT SELECTION-SCREEN
*----- When the button next to Parameter 'F_NAME',
*----- File dialog open.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR F_NAME.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
EXPORTING
WINDOW_TITLE = 'SELECT FILE'
DEFAULT_FILENAME = '*.TXT'
CHANGING
FILE_TABLE = F_TBL
RC = LV_RC
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
OTHERS = 3
*----- system valiable check.
*----- If done properly,
*----- Put the path into the File path parameter
IF SY-SUBRC = 0.
READ TABLE F_TBL INTO STR_F_TBL INDEX 1.
F_NAME = STR_F_TBL.
*----- If not done properly, show message
*----- An error occured while getting file path then end program
ELSE.
MESSAGE E000.
ENDIF.
*----- Execute code can only be A or N.
AT SELECTION-SCREEN ON EXECMODE.
IF EXECMODE <> 'A' AND EXECMODE <> 'N'.
MESSAGE E001.
ENDIF.
START-OF-SELECTION
START-OF-SELECTION.
*----- Upload Local file of file path parameter.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = F_NAME
FILETYPE = 'ASC'
TABLES
DATA_TAB = TBL_LOCAL
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
OTHERS = 6.
*----- System valiable check.
*----- If not done properly, show an error message
*----- An error occured while uploading local file then end program
IF SY-SUBRC <> 0.
MESSAGE E002.
ENDIF.
PERFORM BDC_OPEN.
*----- Loop Internal table
LOOP AT TBL_LOCAL INTO STR_LOCAL.
*----- Spilt the file record and put them into each valiable.
SPLIT STR_LOCAL AT ',' INTO ENUMBER
NAME
BIRTH
HOMETOWN.
*----- Data check Function module
CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
EXPORTING
DATE = BIRTH
EXCEPTIONS
PLAUSIBILITY_CHECK_FAILED = 1
OTHERS = 2.
*----- When error occurs while checking date, show an error message.
*----- (&1) is not date
IF SY-SUBRC <> 0.
MESSAGE E003 WITH BIRTH.
ENDIF.
*-- The first screen of SE11
*----- Screen number 0102 of program id SAPMSRD0
PERFORM BDC_DYNPRO USING 'SAPMSRD0' '0102'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RSRD1-TBMA_VAL'. "Field on Cursor
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=SHOW'. "Display button
PERFORM BDC_FIELD USING 'RSRD1-TBMA'
'X'.
PERFORM BDC_FIELD USING 'RSRD1-TBMA_VAL'
TBL_NAME. "ZT601
*-- Table definition screen
*----- Screen number 2000 of program id SAPLSD02
PERFORM BDC_DYNPRO USING 'SAPLSD02' '2000'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'DD02D-TABCLTEXT'. "Field on Cursor
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=TDED'. "Create entry
PERFORM BDC_FIELD USING 'BDC_SUBSCR'
'SAPLSD02'.
PERFORM BDC_FIELD USING 'BDC_SUBSCR'
'SAPLSED5'.
*-- Data input screen
*----- Screen number 0101 of program /1BCDWB/DBZT601
PERFORM BDC_DYNPRO USING '/1BCDWB/DBZT601' '0101'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'ZT601-CRUSER'. "Field on Cursor
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=SAVE'. "Save
PERFORM BDC_FIELD USING 'ZT601-MANDT'
SY-MANDT. "Client
PERFORM BDC_FIELD USING 'ZT601-ENUMBER'
ENUMBER. "Employee number
PERFORM BDC_FIELD USING 'ZT601-NAME'
NAME. "Employee name
PERFORM BDC_FIELD USING 'ZT601-BIRTH'
BIRTH. "Birthday
PERFORM BDC_FIELD USING 'ZT601-HOMETOWN'
HOMETOWN. "Hometown
PERFORM BDC_FIELD USING 'ZT601-CRDATE'
SY-DATUM. "System date
PERFORM BDC_FIELD USING 'ZT601-CRTIME'
SY-UZEIT. "System time
PERFORM BDC_FIELD USING 'ZT601-CRUSER'
SY-UNAME. "System user
*-- Data input screen (After input)
*----- Screen number 0101 of program /1BCDWB/DBZT601
PERFORM BDC_DYNPRO USING '/1BCDWB/DBZT601' '0101'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/EBACK'. "Back
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'ZT601-CRUSER'. "Field on Cursor
*-- Table definition screen]
*----- Screen number 2000 of program SAPLSD02
PERFORM BDC_DYNPRO USING 'SAPLSD02' '2000'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'DD02D-TABCLTEXT'. "Field on Cursor
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=WB_BACK'. "Back
*-- The first screen of SE11
*----- Screen number 0102 of program SAPMSRD0
PERFORM BDC_DYNPRO USING 'SAPMSRD0' '0102'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RSRD1-TBMA_VAL'. "Field on Cursor
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BACK'.
PERFORM BDC_FIELD USING 'RSRD1-TBMA'
'X'.
PERFORM BDC_FIELD USING 'RSRD1-TBMA_VAL'
TBL_NAME.
PERFORM BDC_INSERT.
ENDLOOP.
PERFORM BDC_CLOSE.
FORM BDC_DYNPRO *
Put Program-Id, Dynpro screen number, Start point
into DBCDATA
--> PROGRAM *
--> DYNPRO *
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDC_TAB.
BDC_TAB-PROGRAM = PROGRAM.
BDC_TAB-DYNPRO = DYNPRO.
BDC_TAB-DYNBEGIN = 'X'.
APPEND BDC_TAB.
ENDFORM.
FORM BDC_FIELD *
Put Field Name and Value into BDCDATA
--> FNAM *
--> FVAL *
FORM BDC_FIELD USING FNAM FVAL.
CLEAR BDC_TAB.
BDC_TAB-FNAM = FNAM.
BDC_TAB-FVAL = FVAL.
APPEND BDC_TAB.
ENDFORM.
FORM bdc_process *
FORM BDC_OPEN.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = 'Testsession'
KEEP = 'X'
USER = SY-UNAME.
IF SY-SUBRC <> 0.
MESSAGE E006 WITH SY-SUBRC.
ENDIF.
ENDFORM.
FORM bdc_insert *
FORM BDC_INSERT.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'SE11'
TABLES
DYNPROTAB = BDC_TAB
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN = 2
QUEUE_ERROR = 3
TCODE_INVALID = 4
PRINTING_INVALID = 5
POSTING_INVALID = 6
OTHERS = 7.
IF SY-SUBRC <> 0.
MESSAGE E007 WITH SY-SUBRC.
ENDIF.
CLEAR: BDC_TAB.
ENDFORM.
FORM bdc_close *
FORM BDC_CLOSE.
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE E008 WITH SY-SUBRC.
ENDIF.
ENDFORM.God I forgot to refresh Internal table after putting record into Session.
Now I'm done.
You guys be careful too. -
Error while creation of Accounting view in background
Hi Experts,
I am creating the Materials using the Function MATERIAL_MAINTAIN_DARK in my program.
I am passing the pstat as appropriate for the views to be created.
Now, my problem comes When i am creating a Plant view and dont require an Accounting view.
Even if I dont pass the PSTAT for the Accounting view, it gives me an exit message saying 'MBEW-BKLAS is defined as a required field.'.
Please help me solve the issue.
Any helpful answer will surely be rewarded.
Thanks in Advance.
Regards,
HimanshuHi,
Please follow the below steps.
Creating the Classification View using the Function module 'BAPI_OBJCL_CREATE'.
Check the Class Type and Class Number which you are passing.
Generally it will be Class type - 001 (Material Class) and Number will be ENGINEERING.
It depends.
But, what you can do is, Check material which has classification data filled.
And just use the same class Type and Class Number Details.
Try this way.It should work.
To know the Available Class Types refer to table TCLA.
Please let me know, if you want further help.
Thanks & Regards,
Vamsi.
Maybe you are looking for
-
How do i change the zoom or size of my entire e-mail
i use fire fox and suddenly my entire e-mail went very small and i know there is a way to enlarge the email print for 50% to 75% etc. i can't find how to get to that font how can i find the way to enlarge my entire e-mail == This happened == Just onc
-
Photoshop CS3 Crashes After Leopard Install
I tried upgrading to Leopard years ago from Tiger but downgraded back because of this same issue. I know I need to upgrade my system so I just installed Leopard again and again the same issue with Photoshop CS3 arises. After the install I am unable t
-
Importing and exporting without losing quality?
I have a Sony HDR-xr200 and a 2.53ghz macbook pro. As it is, I have to import HD footage through the windows conversion on my mac because the stupid Sony camera will only import to a windows based program called PBM. After importing to PBM I have to
-
My employer uses Internet Explorer, and our infoweb is on that homepage. I need firefox for graduate school. (My home internet w/firefox is via satellite which won't fully meet the needs). Can I download firefox to my office desktop without removing
-
Can I skip the step of result recording and only I want usage decision for some purchsed items? Is it mandatory to do result recording? Thanks SD