Bdc to upload a transaction
Hello experts.
My requirement is like this, please help me.
i want to pass data to ke21 transaction. I am fetching data from different tables based on different conditions as per our requirement. i will be having all the data in the internal table .
Now i want to populate the ke21 with the internal table data. I want to populate only 5 screens and rest of the screens i want to ignore it . So please tell me how to write the bdc for this requirement . we will sechudle in the background this job everyday. So please tell me which method to use session or call transaction. Please tell me step by step process what to do.
thanks for all the replies.
Hi
<b>the BDC program should be in this format</b>
Transaction Recorder (SHDB)
How to Upload Presentation Server Flat file to SAP R/3 system???
How to upload application server file to R/3 system?
Definition
Example - Call Transaction Method
<b>Transaction Recorder (SHDB)</b>
Before you work with the Batch Input methods, you should know the purpose of the tool
Transaction Recorder.
Use:
You can use the transaction recorder to record a series of transactions and their screens.
Features:
You can use the recording to create
Data transfer programs that use batch input or CALL TRANSACTION
Batch input sessions
Test data
Function modules.
Note: It doesnt record F1, F4 and Scrollbar movements
<b>Upload Flat file from Presentation Server to SAP R/3</b>
CALL FUNCTION GUI_UPLOAD'
EXPORTING
CODEPAGE = IBM'
FILENAME = P_UFILE
FILETYPE = 'DAT'
TABLES
DATA_TAB = INT_TAB
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
OTHERS = 10 .
IF SY-SUBRC NE 0.
MESSAGE E999(FR) WITH 'ERROR IN FILE UPLOAD'.
ENDIF.
<b>Upload file from application server to SAP R/3</b>
Open the the application server file
OPEN DATASET <dsn> FOR INPUT <mode>
Read the data from application server file
READ DATASET <dsn> INTO <wa>
And then close the application server file
CLOSE DATASET <dsn>
<b>Definition- Declaring BDC Table</b>
DATA: BDC_TAB LIKE STANDARD TABLE OF
BDCDATA INITIAL SIZE 6
WITH HEADER LINE .
The internal table used to collect the transactions information must be declared LIKE BDCDATA.
<b>Filling BDC Table Method #1</b>
FORM FILL_BDC_TAB.
REFRESH BDC_TAB.
CLEAR BDC_TAB.
BDC_TAB-PROGRAM = SAPMF02K.
BDC_TAB-DYNPRO = 01016.
BDC_TAB-DYNBEGIN = X.
APPEND BDC_TAB.
CLEAR BDC_TAB.
BDC_TAB-FNAM = RF02K-LIFNR.
BDC_TAB-FVAL = TEST1.
APPEND BDC_TAB.
CLEAR BDC_TAB.
BDC_TAB-FNAM = RF02K-D0010.
BDC_TAB-FVAL = X.
APPEND BDC_TAB.
CLEAR BDC_TAB.
BDC_TAB-PROGRAM = SAPMF02K.
BDC_TAB-DYNPRO = 0110.
BDC_TAB-DYNBEGIN = X.
APPEND BDC_TAB.
CLEAR BDC_TAB.
BDC_TAB-FNAM = LFA1-STRAS.
BDC_TAB-FVAL = 123 Main St..
APPEND BDC_TAB.
CLEAR BDC_TAB.
BDC_TAB-FNAM = BDC_OKCODE.
BDC_TAB-FVAL = /11.
APPEND BDC_TAB.
ENDFORM.
<b>Filling BDC Table Method #2</b>
FORM FILL_BDC_TAB.
REFRESH BDC_TAB.
PERFORM POPULATE_BDC_TAB
USING:
1 SAPMF02K 0106,
RF02K-LIFNR TEST1,
RF02K-D0010 X,
1 SAPMF02K 0110,
LFA1-STRAS, 123 Main St.,
BDC_OKCODE, /11.
ENDFORM.
FORM POPULATE_BDC_TAB USING FLAG VAR1 VAR2.
CLEAR BDC_TAB.
IF FLAG = 1.
BDC_TAB-PROGRAM = VAR1.
BDC_TAB-DYNPRO = VAR2..
BDC_TAB-DYNBEGIN = X.
ELSE.
BDC_TAB-FNAM = VAR1.
BDC_TAB-FVAL = VAR2.
ENDIF.
APPEND BDC_TAB.
ENDFORM.
This two subroutine method to fill the BDC table is preferable because the POPULATE_BDC_TABLE subroutine is reusable throughout all batch input programs.
<b>Example #1 - Change Vendor (Call Transaction Method)</b>
Example #1- Declaration Section
REPORT Y180DM10.
DATA: BDC_TAB LIKE STANDARD TABLE OF
BDCDATA INITIAL SIZE 6 WITH HEADER LINE.
INFILE(20) VALUE /tmp/bc180_file4.
DATA: BEGIN OF INREC.
VENDNUM LIKE LFA1-LIFNR.
STREET LIKE LFA1-STRAS.
END OF INREC.
PARAMETERS: DISPMODE DEFAULT A,
UPDAMODE DEFAULT S.
START-OF-SELECTION.
OPEN DATASET INFILE
FOR INPUT IN TEXT MODE.
DO.
READ DATASET INFILE INTO INREC.
IF SY-SUBRC < > 0. EXIT. ENDIF.
PERFORM FILL_BDC_TAB.
CALL TRANSACTION FK02
USING BDC_TAB
MODE DISPMODE
UPDATE UPDAMODE.
IF SY-SUBRC < > 0.
WRITE: /ERROR.
ENDIF.
ENDDO.
CLOSE DATASET INFILE.
<b>synchronous updating</b>
DO.
PERFORM FILL_BDC_TAB.
CALL TRANSACTION FK02
USING BDC_TAB
MODE N
UPDATE S.
IF SY-SUBRC < > 0.
WRITE: /ERROR.
ENDIF.
ENDDO.
With synchronous updating, we can check SY-SUBRC to determine the success of the transaction and the actual update to the database.
<b>asynchronous updating</b>
DO.
PERFORM FILL_BDC_TAB.
CALL TRANSACTION FK02
USING BDC_TAB
MODE N
UPDATE A.
IF SY-SUBRC < > 0.
WRITE: /ERROR.
ENDIF.
ENDDO.
With asynchronous updating, we can check SY-SUBRC to determine the success of the transaction only, not the actual update to the database.
<b>Error Handling</b>
Write an error report.
Send the record(s) in error to an error file.
Create a batch input session with the record(s) in error.
To store error messages ( CALL TRANSACTION )
data: begin of Tab_Mess occurs 0.
include structure bdcmsgcoll.
data : end of Tab_Mess,
CALL TRANSACTION FK02 USING BDC_TAB MODE N UPDATE S
MESSAGES INTO TAB_MESS.
IF SY-SUBRC NE 0.
WRITE: / Tab_MESS-TCODE, Tab_MESS-DYNUMB, Tab_MESS-MSGTYP ,
Tab_MESS-MSGID.
ENDIF.
<b>i am giving you example for Change Vendor you practice for ur tcode</b>
For our example, we will use the Change Vendor transaction (FK02) to add a street address to an already existing vendor.
<b>Step #1</b>
Use SystemStatus menu path to determine online program name (SAPMF02K), screen number (0110)
<b>Step #2</b>
Use F1 key and Technical Info pushbutton in each screen field to be filled to determine the field name.
<b>Step #3</b>
Determine how to proceed in the transaction
(save the record by clicking on the Save pushbutton or pressing the F11 key).
<b>BDC Table Contents</b>
After researching the transaction we can determine the contents of the BDC table.
PROGRAM DYNPRO DYNBEGIN FNAM FVAL
SAMPF02K 0106 X
RF02K-LIFNR TEST1
RF02K-D0110 X
SAMPF02K 0110 X
LFA1-STRAS 123 Main St.
BDC_OKCODE /11
<b>Batch Input Methods</b>
CALL TRANSACTION USING
STATEMENT
<b>Call transaction - for data transfer</b>
Processing batch input data with CALL TRANSACTION USING is the faster of the two recommended data transfer methods. In this method, legacy data is processed inline in your data transfer program.
Syntax:
CALL TRANSACTION <tcode>
USING <bdc_tab>
MODE <mode>
UPDATE <update>
A Display all
E Display errors only
N No display
S Synchronous
A Asynchronous
L Local update
<b>The process flow of CALL TRANSACTION</b>
A program that uses CALL TRANSACTION USING to process legacy data should execute thefollowing steps:
Prepare a BDCDATA structure for the transaction that you wish to run.
Prepare a internal table to store error messages Tab_Mess like structure of BDCMSGCOLL.
With a CALL TRANSACTION USING statement, call the transaction and prepare the BDCDATA structure. For example:
CALL TRANSACTION MM01' USING BDCDATA MODE 'A' UPDATE 'S'. MESSAGES INTO TAB_MESS.
IF SY-SUBRC <> 0.
<Error_handling>.
ENDIF.
<b>Overview of Batch Input Session</b>
The first batch input method is to create a batch input session. It is the processing of this batch input session that updates the database, not the execution of the batch input program.
<b>Reward if usefull</b>
Similar Messages
-
Problem in BDC program using MIGO_GO transaction code
Hi Gurus
I have developed a BDC session upload program. The program is
running fine except for the issue that when it goes the subscreen in
MIGO_GO transaction (same as MIGO) it does not generates any code
for page down or next page key. While recording after 15 entries
(end of page) it moves automaticaly to the next page on line 2 but
when I have used my own itab to fill data into this screen it
passes/generates the code for page down with clear screen. It does
go to item 2 but overwrites earlier entries instead of generting new
one.
Any suggestions?
Guys this is very urgent so need ur feedback immediately?
Lots of thanks in advance.
The code is as follows:
PURPOSE: The purpose of this upload program is to upload
receipt
against Production Order. Data is uploaded into SAP
via text
file which is converted from pre-defined excel file
pattern.
REPORT zmm_migo_rec
NO STANDARD PAGE HEADING LINE-SIZE 255.
*Excel column sequence SAP Material Number Batch # Crop Year
Process Date Net Weight Plant Area Gross
Weight Plant Number Shift Mat.Desc Prod.Ord#
TYPES : BEGIN OF st_barcode,
m_matnr LIKE mara-matnr,
m_batch_no LIKE mseg-charg,
m_crop_year TYPE c LENGTH 4,
m_process_date LIKE mkpf-bldat,
m_net_wt TYPE c LENGTH 7,
m_plant_area TYPE c LENGTH 5,
m_gross_wt TYPE c LENGTH 7,
m_plant_num TYPE c LENGTH 1,
m_shift TYPE c LENGTH 1,
m_matnr_desc TYPE c LENGTH 30,
m_prod_ord LIKE mseg-aufnr,
text(200),
text1(200),
END OF st_barcode.
DATA : itab_barcode TYPE TABLE OF st_barcode WITH HEADER LINE.
DATA : itab_log TYPE TABLE OF st_barcode WITH HEADER LINE.
DATA : itab_log1 TYPE TABLE OF st_barcode WITH HEADER LINE.
DATA : g_filename TYPE rlgrap-filename.
INCLUDE bdcrecx1.
Start of Selection Screen for document data, screen data and
posting date fields.
SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-000.
PARAMETERS :
p_dummy TYPE i DEFAULT 0,
p_bldat LIKE sy-datum OBLIGATORY DEFAULT sy-
datum, "Document date
p_budat LIKE sy-datum OBLIGATORY DEFAULT sy-
datum, "Posting date
p_frmplt LIKE t001l-werks OBLIGATORY,
p_frmloc LIKE t001l-lgort OBLIGATORY,
p_toloc LIKE t001l-lgort OBLIGATORY,
p_rsnmov LIKE mseg-grund OBLIGATORY,
p_bsarea LIKE mseg-gsber OBLIGATORY,
cb_simul AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK a1.
START-OF-SELECTION.
*to remove unnecessary fields from selection screen
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-group4 LT '060' AND screen-group3 NE 'BLK'.
screen-active = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
*to Process Call Transaction in Error Mode
ctu = 'X'.
ctumode = 'A'.
nodata = space.
END-OF-SELECTION.
Get data from file
PERFORM f_get_data.
Validate data retrieved from excel file
PERFORM f_validate_data.
Batch data / simulate.
IF cb_simul IS INITIAL.
PERFORM f_prized_data.
PERFORM f_write_log.
ELSE.
PERFORM f_write_log.
ENDIF.
*& Form F_GET_DATA
This module is used to read text file data into SAP itab.
FORM f_get_data .
Select the file to be uploaded
CALL FUNCTION 'UPLOAD'
EXPORTING
filename = g_filename
filetype = 'DAT'
TABLES
data_tab = itab_barcode
EXCEPTIONS
conversion_error = 1
invalid_table_width = 2
invalid_type = 3
no_batch = 4
unknown_error = 5
gui_refuse_filetransfer = 6
OTHERS = 7.
ENDFORM. " F_GET_DATA
*& Form F_VALIDATE_DATA
text
FORM f_validate_data .
DATA : BEGIN OF lt_marc OCCURS 0,
matnr LIKE mard-matnr,
werks LIKE mard-werks, " Plant
END OF lt_marc.
RANGES : lr_matnr FOR mara-matnr.
READ TABLE itab_barcode INDEX 1.
Prepare Ranges to check/verify Material from Table MARD i.e.
respective plant
lr_matnr-sign = 'I'.
lr_matnr-option = 'EQ'.
LOOP AT itab_barcode.
Add leading zeros incase of numeric value.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = itab_barcode-m_matnr
IMPORTING
output = itab_barcode-m_matnr.
lr_matnr-low = itab_barcode-m_matnr.
APPEND lr_matnr.
MODIFY itab_barcode TRANSPORTING m_matnr.
ENDLOOP.
IF NOT lr_matnr[] IS INITIAL.
SORT lr_matnr BY low.
DELETE ADJACENT DUPLICATES FROM lr_matnr COMPARING low.
SELECT matnr werks FROM marc
INTO TABLE lt_marc
WHERE matnr IN lr_matnr AND
werks = p_frmplt.
ENDIF.
LOOP AT itab_barcode.
READ TABLE lt_marc
WITH KEY matnr = itab_barcode-m_matnr
werks = p_frmplt.
IF sy-subrc <> 0 .
CONCATENATE 'Material' itab_barcode-m_matnr
' does not exist in Plant ' p_frmplt
INTO itab_barcode-text SEPARATED BY space.
MOVE-CORRESPONDING itab_barcode TO itab_log.
APPEND itab_log.
MODIFY itab_barcode TRANSPORTING text.
CONTINUE.
ENDIF.
ENDLOOP.
ENDFORM. " F_VALIDATE_DATA
*& Form F_WRITE_LOG
text
FORM f_write_log .
LOOP AT itab_log.
WRITE :/ itab_log-text.
ENDLOOP.
LOOP AT itab_log1.
WRITE :/ itab_log1-text1.
ENDLOOP.
ENDFORM. " F_WRITE_LOG
*& Form f_prized_data
text
--> p1 text
<-- p2 text
FORM f_prized_data.
DATA: ld_lines LIKE sy-tabix,
ld_sw TYPE i,
lh_loop TYPE i,
ld_recno TYPE i,
lremain TYPE i,
ld_total TYPE i,
ld_counter LIKE sy-index,
ld_counter TYPE i,
ld_save LIKE sy-index,
ld_last TYPE i,
sc_counter(2) TYPE n,
ld_budat(10),
ld_bldat(10).
DATA: wa_matnr(40) TYPE c,
wa_bwtar(40) TYPE c,
wa_erfme(40) TYPE c,
wa_charg(40) TYPE c.
WRITE: p_budat TO ld_budat,
p_bldat TO ld_bldat.
ld_recno = 300. " Number of records in the upload file.
ld_last = 0.
Open BDC session.
PERFORM open_group.
DESCRIBE TABLE itab_barcode LINES ld_lines.
CLEAR: lh_loop, lremain.
lh_loop = ld_lines DIV ld_recno.
lremain = ld_lines MOD ld_recno.
IF lremain > 0.
lh_loop = lh_loop + 1.
ENDIF.
ld_sw = 1.
LOOP AT itab_barcode.
ADD 1 TO ld_counter.
ADD 1 TO sc_counter.
ADD 1 TO ld_total. " Check for 300
IF ld_sw = 1.
Header data.
PERFORM open_group.
PERFORM bdc_dynpro USING 'SAPLMIGO' '0001'.
PERFORM bdc_field
USING 'BDC_OKCODE' '=MIGO_OK_ACTION'.
PERFORM bdc_field
USING 'BDC_CURSOR' 'GODYNPRO-ACTION'.
PERFORM bdc_field USING 'GODYNPRO-
ACTION' 'A01'.
PERFORM bdc_field USING 'GODYNPRO-
REFDOC' 'R02'.
PERFORM bdc_dynpro USING 'SAPLMIGO' '0001'.
PERFORM bdc_field
USING 'BDC_OKCODE' '=OK_GO'.
PERFORM bdc_field USING 'GODYNPRO-
ACTION' 'A01'.
PERFORM bdc_field USING 'GODYNPRO-
REFDOC' 'R08'.
PERFORM bdc_field USING 'GODEFAULT_TV-
BWART' '101'.
PERFORM bdc_field
USING 'BDC_CURSOR' 'GODYNPRO-
ORDER_NUMBER'.
PERFORM bdc_field USING 'GOHEAD-
BLDAT' ld_bldat.
PERFORM bdc_field USING 'GOHEAD-
BUDAT' ld_budat.
PERFORM bdc_field USING 'GOHEAD-
XNAPR' 'X'.
PERFORM bdc_dynpro USING 'SAPLMIGO' '0001'.
PERFORM bdc_field
USING 'BDC_OKCODE' '=MIGO_OK_DETAIL_OP
EN'.
PERFORM bdc_field USING 'GODYNPRO-
ACTION' 'A01'.
PERFORM bdc_field USING 'GODYNPRO-
REFDOC' 'R08'.
PERFORM bdc_field USING 'GODEFAULT_TV-
BWART' '101'.
PERFORM bdc_field
USING 'BDC_CURSOR' 'GODYNPRO-
ORDER_NUMBER'.
PERFORM bdc_field USING 'GOHEAD-
BLDAT' ld_bldat.
PERFORM bdc_field USING 'GOHEAD-
BUDAT' ld_budat.
PERFORM bdc_field USING 'GOHEAD-
XNAPR' 'X'.
PERFORM bdc_dynpro USING 'SAPLMIGO' '0001'.
PERFORM bdc_field
USING 'BDC_OKCODE' '=OK_GO'.
PERFORM bdc_field USING 'GODYNPRO-
ACTION' 'A01'.
PERFORM bdc_field USING 'GODYNPRO-
REFDOC' 'R08'.
PERFORM bdc_field USING 'GODEFAULT_TV-
BWART' '101'.
PERFORM bdc_field
USING 'BDC_CURSOR' 'GODYNPRO-
ORDER_NUMBER'.
PERFORM bdc_field USING 'GODYNPRO-
ORDER_NUMBER' itab_barcode-m_prod_ord.
PERFORM bdc_field USING 'GOHEAD-
BLDAT' ld_bldat.
PERFORM bdc_field USING 'GOHEAD-
BUDAT' ld_budat.
PERFORM bdc_field USING 'GOHEAD-
XNAPR' 'X'.
PERFORM bdc_dynpro USING 'SAPLMIGO' '0001'.
PERFORM bdc_field
USING 'BDC_OKCODE' '=MIGO_OK_LINE_CLIC
K'.
PERFORM bdc_field USING 'GODEFAULT_TV-
BWART' '101'.
PERFORM bdc_field USING 'GOHEAD-
BLDAT' ld_bldat.
PERFORM bdc_field USING 'GOHEAD-
BUDAT' ld_budat.
PERFORM bdc_field USING 'GOHEAD-
XNAPR' 'X'.
PERFORM bdc_field USING 'GOHEAD-
WEVER' '3'.
PERFORM bdc_field
USING 'BDC_CURSOR' 'GOITEM-ZEILE(01)'.
PERFORM bdc_field USING 'GODYNPRO-
DETAIL_ZEILE' ' 1'.
PERFORM bdc_field USING 'GOITEM-
ERFME' 'KG'.
PERFORM bdc_field USING 'GOITEM-
BWART' '101'.
PERFORM bdc_dynpro USING 'SAPLMIGO' '0001'.
PERFORM bdc_field
USING 'BDC_OKCODE' '=MIGO_OK_SPLIT_QUA
N'.
PERFORM bdc_field USING 'GODEFAULT_TV-
BWART' '101'.
PERFORM bdc_field USING 'GOHEAD-
BLDAT' ld_bldat.
PERFORM bdc_field USING 'GOHEAD-
BUDAT' ld_budat.
PERFORM bdc_field USING 'GOHEAD-
XNAPR' 'X'.
PERFORM bdc_field USING 'GOHEAD-
WEVER' '3'.
PERFORM bdc_field
USING 'BDC_CURSOR' 'GOITEM-ZEILE(01)'.
PERFORM bdc_field USING 'GODYNPRO-
DETAIL_ZEILE' ' 1'.
PERFORM bdc_field USING 'GOITEM-
ERFME' 'KG'.
PERFORM bdc_field USING 'GOITEM-
MIGO_ELIKZ' '1'.
PERFORM bdc_field USING 'GOITEM-
BWART' '101'.
ld_sw = 0.
ENDIF.
IF sc_counter = 16.
CLEAR sc_counter.
PERFORM bdc_field USING 'BDC_OKCODE' 'DOWN'.
PERFORM bdc_field
USING 'BDC_OKCODE' '/00'.
add 2 to sc_counter.
ELSE.
PERFORM bdc_field USING 'BDC_OKCODE' '/00'.
ENDIF.
CLEAR wa_matnr.
CONCATENATE 'GOSPLIT-ERFMG(' sc_counter ')' INTO wa_matnr.
CLEAR wa_bwtar.
CONCATENATE 'GOSPLIT-CHARG(' sc_counter ')' INTO wa_bwtar.
PERFORM bdc_dynpro USING 'SAPLMIGO' '1000'.
PERFORM bdc_field
USING 'BDC_OKCODE' '=OK_SP_CH'.
PERFORM bdc_field
USING 'BDC_CURSOR' 'GOSPLIT-CHARG
(sc_counter)'.
PERFORM bdc_field USING wa_matnr itab_barcode-
m_gross_wt.
PERFORM bdc_field USING wa_bwtar itab_barcode-
m_batch_no.
PERFORM bdc_field
USING 'BDC_CURSOR' 'GOSPLIT-CHARG
(sc_counter)'.
*When end of itab
AT LAST.
PERFORM bdc_dynpro USING 'SAPLMIGO' '1000'.
PERFORM bdc_field
USING 'BDC_OKCODE' '=OK_GOON'.
PERFORM bdc_field
USING 'BDC_CURSOR' 'GOSPLIT-CHARG
(sc_counter)'.
PERFORM bdc_dynpro USING 'SAPLMIGO' '0001'.
PERFORM bdc_field
USING 'BDC_OKCODE' '=MIGO_OK_NEXT_IT'.
PERFORM bdc_field USING 'GODEFAULT_TV-
BWART' '101'.
PERFORM bdc_field USING 'GOHEAD-
BLDAT' ld_bldat.
PERFORM bdc_field USING 'GOHEAD-
BUDAT' ld_budat.
PERFORM bdc_field USING 'GOHEAD-
XNAPR' 'X'.
PERFORM bdc_field USING 'GOHEAD-
WEVER' '3'.
PERFORM bdc_field
USING 'BDC_CURSOR' 'GOITEM-ZEILE(01)'.
PERFORM bdc_field USING 'GODYNPRO-
DETAIL_ZEILE' ' 1'.
PERFORM bdc_field USING 'GOITEM-
ERFME' 'KG'.
PERFORM bdc_field USING 'GOITEM-
MIGO_ELIKZ' '1'.
PERFORM bdc_field USING 'GOITEM-
BWART' '101'.
PERFORM bdc_dynpro USING 'SAPLMIGO' '0001'.
PERFORM bdc_field
USING 'BDC_OKCODE' '=MIGO_OK_TAKE_VALU
E'.
PERFORM bdc_field USING 'GODEFAULT_TV-
BWART' '101'.
PERFORM bdc_field USING 'GOHEAD-
BLDAT' ld_bldat.
PERFORM bdc_field USING 'GOHEAD-
BUDAT' ld_budat.
PERFORM bdc_field USING 'GOHEAD-
XNAPR' 'X'.
PERFORM bdc_field
USING 'BDC_CURSOR' 'GOITEM-TAKE_IT
(01)'.
PERFORM bdc_field USING 'GOITEM-TAKE_IT
(01)' 'X'.
PERFORM bdc_field USING 'GODYNPRO-
DETAIL_ZEILE' ' 1'.
PERFORM bdc_field USING 'GOITEM-
ERFME' 'KG'.
PERFORM bdc_field USING 'GOITEM-
MIGO_ELIKZ' '1'.
PERFORM bdc_field USING 'GOITEM-
BWART' '101'.
PERFORM bdc_dynpro USING 'SAPLMIGO' '0001'.
PERFORM bdc_field
USING 'BDC_OKCODE' '=OK_CHECK'.
PERFORM bdc_field USING 'GODEFAULT_TV-
BWART' '101'.
PERFORM bdc_field USING 'GOHEAD-
BLDAT' ld_bldat.
PERFORM bdc_field USING 'GOHEAD-
BUDAT' ld_budat.
PERFORM bdc_field USING 'GOHEAD-
XNAPR' 'X'.
PERFORM bdc_field
USING 'BDC_CURSOR' 'GOITEM-TAKE_IT
(01)'.
PERFORM bdc_field USING 'GODYNPRO-
DETAIL_ZEILE' ' 1'.
PERFORM bdc_field USING 'GOITEM-
ERFME' 'KG'.
PERFORM bdc_field USING 'GOITEM-
MIGO_ELIKZ' '1'.
PERFORM bdc_field USING 'GOITEM-
BWART' '101'.
PERFORM bdc_field USING 'GODYNPRO-
DETAIL_TAKE' 'X'.
PERFORM bdc_dynpro USING 'SAPMSSY0' '0120'.
PERFORM bdc_field
USING 'BDC_OKCODE' '=&ONT'.
PERFORM bdc_dynpro USING 'SAPLMIGO' '0001'.
PERFORM bdc_field
USING 'BDC_OKCODE' '=OK_POST1'.
PERFORM bdc_field USING 'GODEFAULT_TV-
BWART' '101'.
PERFORM bdc_field USING 'GOHEAD-
BLDAT' ld_bldat.
PERFORM bdc_field USING 'GOHEAD-
BUDAT' ld_budat.
PERFORM bdc_field USING 'GOHEAD-
XNAPR' 'X'.
PERFORM bdc_field
USING 'BDC_CURSOR' 'GOITEM-TAKE_IT
(01)'.
PERFORM bdc_field USING 'GODYNPRO-
DETAIL_ZEILE' ' 1'.
PERFORM bdc_field USING 'GOITEM-
ERFME' 'KG'.
PERFORM bdc_field USING 'GOITEM-
MIGO_ELIKZ' '1'.
PERFORM bdc_field USING 'GOITEM-
BWART' '101'.
PERFORM bdc_field USING 'GODYNPRO-
DETAIL_TAKE' 'X'.
PERFORM bdc_transaction USING 'MIGO_GO'.
ENDAT.
ENDLOOP.
PERFORM close_group.
ENDFORM. "f_prized_dataHi
Thanks Peram for your swift reply but I am a newbie to BAPIs ...... is there anyway i can do this from within the code i had written ....
for BAPIs I have to do R & D in detail and I need to complete this urgently. If BAPI is the only solution kindly provide my some quick guideline to proceed.
Thanks,
Imran -
i need some code for BDC upload of tcode FB50.
Reward points will be given to good answers
tanayaHi
See the sample BDC program for a FI transaction
look at it and do the recording for FB50 using SHDB and do it.
REPORT ZFIBDC1_1 NO STANDARD PAGE HEADING MESSAGE-ID ZT.
Declaration of internal tables
internal table for selecting data from flat file
DATA : BEGIN OF IT_DATA OCCURS 0,
BLDAT(10), " Document Date
BUDAT(10), " Posting date
NEWBS(2), " Posting key
NEWKO(17), " Vendor account
NEWUM, " G/L indicator
WRBTR(16), " Amount
SGTXT(50), " Text
PRCTR(10), " Profit center
END OF IT_DATA.
internal table for bdcdata
DATA : IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
internal table to handle messages
DATA : IT_MESSAGES LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
Variables & Flag declaration
variables declaration
DATA : V_MESG(50).
flag declaration
DATA : V_BLART(2) VALUE 'AB', " Document Type
V_NEWBS1(2) VALUE '40', " Posting Key
V_NEWKO1(17) VALUE '171110 ', " GL account
FG_BDC,
FG_FLAG1 TYPE I.
selection screen
SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.
parameter
PARAMETERS : P_FILE LIKE RLGRAP-FILENAME OBLIGATORY.
SELECTION-SCREEN END OF BLOCK BLK1.
initialization
INITIALIZATION.
peform to initialize parameter
PERFORM INIT_PARM.
start of selection
start-of-selection.
perform to upload it_data
PERFORM UP_LOAD_IT_DATA.
perform transfer data
PERFORM TRANSFER_DATA.
end of selection
END-OF-SELECTION.
*& Form INIT_PARM
Initializing parameter
FORM INIT_PARM.
P_FILE = 'C:\'.
ENDFORM. " INIT_PARM
*& Form UP_LOAD_IT_DATA
Transfering data from file to internal table
FORM UP_LOAD_IT_DATA.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = P_FILE
FILETYPE = 'ASC'
TABLES
DATA_TAB = IT_DATA
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TABLE_WIDTH = 4
INVALID_TYPE = 5
NO_BATCH = 6
UNKNOWN_ERROR = 7
GUI_REFUSE_FILETRANSFER = 8
OTHERS = 9.
IF SY-SUBRC = 2 .
FG_FLAG1 = 1.
MESSAGE I001.
ENDIF.
ENDFORM. " UP_LOAD_IT_DATA
*& Form TRANSFER_DATA
Processing the data
FORM TRANSFER_DATA.
FG_BDC = 'N'.
LOOP AT IT_DATA.
perform to fill it_bdcdata.
PERFORM FILL_IT_BDCDATA.
CALL TRANSACTION 'F-51' USING IT_BDCDATA MODE 'N' UPDATE 'S'
MESSAGES INTO IT_MESSAGES.
IF SY-SUBRC <> 0.
FG_FLAG1 = 1.
if error occurs in transaction mode run bdc session for that data
PERFORM BDC_PROCESS.
ENDIF.
Handles error messages
PERFORM ERROR_MESSAGES.
CLEAR : IT_BDCDATA,IT_DATA,IT_MESSAGES.
REFRESH : IT_BDCDATA,IT_MESSAGES.
ENDLOOP.
IF FG_FLAG1 = 0.
MESSAGE I003.
ENDIF.
IF FG_BDC = 'O'.
close bdc if it is open
PERFORM CLOSE_BDC.
ENDIF.
ENDFORM. " TRANSFER_DATA
*& Form FILL_IT_BDCDATA
Filling Bdcdata structure with it_data
Some fields have been commented for future updations --------------*
FORM FILL_IT_BDCDATA.
PERFORM BDC_DYNPRO USING : 'SAPMF05A' '0122'.
PERFORM BDC_FIELD USING : 'BDC_OKCODE' '/00',
: 'BDC_CURSOR' 'RF05A-NEWUM',
: 'BKPF-BLDAT' IT_DATA-BLDAT,
: 'BKPF-BLART' V_BLART,
: 'BKPF-BUKRS' 'NBC1',
: 'BKPF-BUDAT' IT_DATA-BUDAT,
: 'BKPF-WAERS' 'INR',
: 'RF05A-NEWBS' IT_DATA-NEWBS,
: 'RF05A-NEWKO' 'E1',
: 'RF05A-NEWUM' IT_DATA-NEWUM,
: 'RF05A-XPOS1(04)' 'X'.
IF IT_DATA-NEWUM IS INITIAL.
PERFORM BDC_DYNPRO USING : 'SAPMF05A' '0302'.
PERFORM BDC_FIELD USING : 'BDC_OKCODE' '/00',
'BDC_CURSOR' 'RF05A-NEWKO',
'BSEG-WRBTR' IT_DATA-WRBTR,
'BSEG-SGTXT' IT_DATA-SGTXT,
'RF05A-NEWBS' V_NEWBS1,
'RF05A-NEWKO' V_NEWKO1.
PERFORM BDC_DYNPRO USING : 'SAPMF05A' '0300'.
PERFORM BDC_FIELD USING : 'BDC_OKCODE' '/00',
'BDC_CURSOR' 'BSEG-SGTXT',
'BSEG-WRBTR' '*',
'BSEG-SGTXT' '+',
'BDC_SUBSCR' 'saplkacb'.
PERFORM BDC_DYNPRO USING : 'SAPLKACB' '0002'.
PERFORM BDC_FIELD USING : 'BDC_OKCODE' '=ENTE',
'BDC_CURSOR' 'COBL-PRCTR',
'COBL-PRCTR' IT_DATA-PRCTR,
'BDC_SUBSCR' 'SAPLKACB'.
PERFORM BDC_DYNPRO USING : 'SAPMF05A' '0300'.
PERFORM BDC_FIELD USING : 'BDC_OKCODE' '=BU',
'BDC_CURSOR' 'BSEG-WRBTR',
'BDC_SUBSCR' 'SAPLKACB'.
PERFORM BDC_DYNPRO USING : 'SAPLKACB' '0002'.
PERFORM BDC_FIELD USING : 'BDC_OKCODE' '=ENTE',
'BDC_CURSOR' 'COBL-AUFNR',
'BDC_SUBSCR' 'SAPLKACB'.
ELSE.
PERFORM BDC_DYNPRO USING : 'SAPMF05A' '0304'.
PERFORM BDC_FIELD USING : 'BDC_OKCODE' '/00',
'BDC_CURSOR' 'RF05A-NEWKO',
'BSEG-WRBTR' IT_DATA-WRBTR,
'BSEG-PRCTR' IT_DATA-PRCTR,
'BSEG-SGTXT' IT_DATA-SGTXT,
'RF05A-NEWBS' V_NEWBS1,
'RF05A-NEWKO' V_NEWKO1.
PERFORM BDC_DYNPRO USING : 'SAPMF05A' '0300'.
PERFORM BDC_FIELD USING : 'BDC_OKCODE' '=BU',
'BDC_CURSOR' 'BSEG-SGTXT',
'BSEG-WRBTR' '*',
'BSEG-SGTXT' '+',
'BDC_SUBSCR' 'saplkacb'.
PERFORM BDC_DYNPRO USING : 'SAPLKACB' '0002'.
PERFORM BDC_FIELD USING : 'BDC_OKCODE' '=ENTE',
'BDC_CURSOR' 'COBL-PRCTR',
'COBL-PRCTR' IT_DATA-PRCTR,
'BDC_SUBSCR' 'SAPLKACB'.
ENDIF.
ENDFORM. " FILL_IT_BDCDATA
*& Form BDC_DYNPRO
Filling the it_bdcdata table with program name & screen number
FORM BDC_DYNPRO USING PROGRAM LIKE BDCDATA-PROGRAM
DYNPRO LIKE BDCDATA-DYNPRO.
IT_BDCDATA-PROGRAM = PROGRAM.
IT_BDCDATA-DYNPRO = DYNPRO.
IT_BDCDATA-DYNBEGIN = 'X'.
APPEND IT_BDCDATA.
CLEAR IT_BDCDATA.
ENDFORM. " BDC_DYNPRO
*& Form BDC_FIELD
Filling it_bdcdata with field name and field value
FORM BDC_FIELD USING FNAM LIKE BDCDATA-FNAM
FVAL.
IT_BDCDATA-FNAM = FNAM.
IT_BDCDATA-FVAL = FVAL.
APPEND IT_BDCDATA.
CLEAR IT_BDCDATA.
ENDFORM. " BDC_FIELD
*& Form BDC_PROCESS
Open bdc session if call transaction fails
FORM BDC_PROCESS.
IF FG_BDC = 'N'.
open bdc session
PERFORM OPEN_BDC.
FG_BDC = 'O'.
ENDIF.
IF FG_BDC = 'O'.
insert data into bdc session
PERFORM INSERT_BDC.
ENDIF.
ENDFORM. " BDC_PROCESS
*& Form OPEN_BDC
Calling function module to open bdc session
FORM OPEN_BDC.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = 'SMM1'
KEEP = 'X'
USER = SY-UNAME
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.
ENDFORM. " OPEN_BDC
*& Form INSERT_BDC
Insert it_bdcdata into bdc by calling function module bdc_insert
FORM INSERT_BDC.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'MM01'
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.
ENDFORM. " INSERT_BDC
*& Form ERROR_MESSAGES
Displaying error messages
FORM ERROR_MESSAGES.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = SY-MSGID
LANG = '-D'
IMPORTING
MSG = V_MESG
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
LOOP AT IT_MESSAGES WHERE MSGTYP = 'E'.
WRITE : / 'Message :'(I06) ,V_MESG.
CLEAR IT_MESSAGES.
ENDLOOP.
ENDFORM. " ERROR_MESSAGES
*& Form CLOSE_BDC
Closing bdc session
FORM CLOSE_BDC.
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3.
ENDFORM. " CLOSE_BDC
<b>Reward points for useful Answers</b>
Regards
Anji -
How To... Update Master Data during upload of transaction data
Can anybody let me know how this can be achieved.
I have datasource (Legacy not R3) where I am getting both master data and text for number of infoobjects.
I dont want separate datasources.
The datasource is actually transactional datasource.
I dont need text in the cubes or DSO I need the text tables of the infoobjects to be updated.
I could find this on SDN but do anyone have document based on the below link.I was not able to find it.
How To... Update Master Data during upload of transaction data
Thanks.Dear Praveen
I guess yr req is demanding the knowledge of Data Unification and Synchronization whose scope is a bit outer the area of BW.( its MDM actually )
In BW we could very well fetch data out of different data sources (even across the different system) with no issues so why not u trying that. if there is any issue implementing that then please specify what kind of trouble you are interfacing...
I got the below link which may be helpful
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e7bd6389-0a01-0010-eb95-d45835d446a8 -
How to handle table control in BDC while uploading item details for anorder
How to handle table control in BDC while uploading item details for an order?
What is the use of CTU_PARAMS structure in BDC?
In Finance I have done some changes to the layout set by coping to a zscript(duning letter) and how can assign the print program?
What is the process to test the finance script?
How can I see the print preview whether it is coming correctly or not?
Thanks in advance.
Regards.
Abhilash.hi,
for the bdc control refer the following link:
http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
ctu_params:
refer to the link
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/abap/dataTransfers-LSMW%2CALE%2C+BDC
reward if useful,
thanks and regards -
Can i upload first Transaction data rather than master data what will hap
hai,
can i upload first Transaction data rather than master data what happends going in bw regarding performance issues like indexes
let me know
regards,
muraliHi Murali,
you can load the transaction data before master data. The main impact will be, that the system has to generate sid's and has to populate the sid-table of the master data objects while loading the data to a data target (cube or ods that is activated for bex reporting). This basically means that your data loads will take some more time. Additionally, if you need the master data attributes somewhere in your update or transfer rules, you will not get the correct information.
So basically it is always a good approach to load and activate the master data before loading the transactional data. But anyway, specially in the development environment I usually don't load all the necessary master data.
regards
Siggi
PS: navigational attributes of the data targets will not be available until you loaded the master data and scheduled the attribute and hierarchy change run.
Message was edited by: Siegfried Szameitat -
BDC Recording for cm07 Transaction
Hi Everyone,
I'm doing BDC recording for CM07 transaction. In Recording, i need to give a print command by specifying the spool title.
For this, after opening the print window, i need to click the 'properties' button, and then select the spool title and input the value.
But I'm unable to do the recording of this print dialog box. The recording ends as soon as I give the print command.
Can anyone please tell me the solution to it.
Thanks and Regards
Rishika bawaHi,
See via transaction SHDB:
SAPLCORU_S 0100 X
BDC_OKCODE BU
AFRUD-RUECK 0000000000
AFRUD-AUFNR 100051152
AFRUD-VORNR 0010
AFRUD-LMNGA 100,000
AFRUD-MEINH PC
AFRUD-XMNGA 2,000
AFRUD-ISM01 200
AFRUD-ILE01 PC
The table for confirmations is AFRU.
Best regards,
Leandro Mengue -
Request for sample Functional Specification for BDC to upload PA40 or PA30
Hi Experts
I need to Write a Functional specification to Guide My ABAP team member to write a BDC for uploading data in PA40.
It would be great if somebody could spare me one .
Thanks in advance
Rajeev Chhabra
<u>[email protected]</u>Hi Rajeev,
Your company might be having standard format of FS.
Writing a FS for a BDC is not that tough job. You need to provide some basic information such as the file structure to be used in BDC, Number of fields in the file, which fields on the screen need to be populated (you can get the fields technical name by doing F1 on the field).
I think you can use this as a guideline to write your own FS.
Regards,
Atish -
Hi All,,
Please give Entire BDC code for MM01 Transaction.
i will change as per my requirement.
I think this is already done by some ABAP Consultants.
plz dont give answers like do recording for that transaction MM01. I know recording...
For time constraiint, I have to complete soon.....
Thanks in Advance
BestRegards,
AnilHi,
The below code is using the Session Method
report ZDS_BDC_MM01
no standard page heading line-size 255.
include bdcrecx1.
*parameters: dataset(132) lower case.
*** DO NOT CHANGE - the generated data section - DO NOT CHANGE ***
* If it is nessesary to change the data section use the rules:
* 1.) Each definition of a field exists of two lines
* 2.) The first line shows exactly the comment
* '* data element: ' followed with the data element
* which describes the field.
* If you don't have a data element use the
* comment without a data element name
* 3.) The second line shows the fieldname of the
* structure, the fieldname must consist of
* a fieldname and optional the character '_' and
* three numbers and the field length in brackets
* 4.) Each field must be type C.
*** Generated data section with specific formatting - DO NOT CHANGE ***
data: begin of record OCCURS 0,
* data element: MATNR
MATNR_001(018),
* data element: MBRSH
MBRSH_002(001),
* data element: MTART
MTART_003(004),
* data element: XFELD
KZSEL_01_004(001),
* data element: XFELD
KZSEL_02_005(001),
* data element: MAKTX
MAKTX_006(040),
* data element: MEINS
MEINS_007(003),
* data element: MAKTX
MAKTX_008(040),
end of record.
*** End generated data section ***
start-of-selection.
*perform open_dataset using dataset.
perform open_group.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME ='C:\DHRUV.TXT'
FILETYPE = 'DAT'
* HAS_FIELD_SEPARATOR = ' '
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* VIRUS_SCAN_PROFILE =
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
DATA_TAB = RECORD
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.
*do.
LOOP AT record.
*read dataset dataset into record.
if sy-subrc <> 0. exit. endif.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RMMG1-MATNR'
record-MATNR_001.
perform bdc_field using 'RMMG1-MBRSH'
record-MBRSH_002.
perform bdc_field using 'RMMG1-MTART'
record-MTART_003.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(02)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
record-KZSEL_01_004.
perform bdc_field using 'MSICHTAUSW-KZSEL(02)'
record-KZSEL_02_005.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
record-MAKTX_006.
perform bdc_field using 'BDC_CURSOR'
'MARA-MEINS'.
perform bdc_field using 'MARA-MEINS'
record-MEINS_007.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BDC_CURSOR'
'MAKT-MAKTX'.
perform bdc_field using 'MAKT-MAKTX'
record-MAKTX_008.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
perform bdc_transaction using 'MM01'.
*enddo.
ENDLOOP.
perform close_group.
*perform close_dataset using dataset.
*Text elements
* E00 Error opening dataset, return code:
* I01 Session name
* I02 Open session
* I03 Insert transaction
* I04 Close Session
* I05 Return code =
* I06 Error session created
* S01 Session name
* S02 User
* S03 Keep session
* S04 Lock date
* S05 Processing Mode
* S06 Update Mode
* S07 Generate session
* S08 Call transaction
* S09 Error sessn
* S10 Nodata indicator
* S11 Short log
*Messages
* Message class: MS
*613 Please enter a session name and user name
The Below is the coding for the Call Transaction...
report ZDS_BDC_MM01_2
no standard page heading line-size 255.
*include bdcrecx1.
*parameters: dataset(132) lower case.
*** DO NOT CHANGE - the generated data section - DO NOT CHANGE ***
* If it is nessesary to change the data section use the rules:
* 1.) Each definition of a field exists of two lines
* 2.) The first line shows exactly the comment
* '* data element: ' followed with the data element
* which describes the field.
* If you don't have a data element use the
* comment without a data element name
* 3.) The second line shows the fieldname of the
* structure, the fieldname must consist of
* a fieldname and optional the character '_' and
* three numbers and the field length in brackets
* 4.) Each field must be type C.
*** Generated data section with specific formatting - DO NOT CHANGE ***
data: begin of record OCCURS 0,
* data element: MATNR
MATNR_001(018),
* data element: MBRSH
MBRSH_002(001),
* data element: MTART
MTART_003(004),
* data element: XFELD
KZSEL_01_004(001),
* data element: MAKTX
MAKTX_005(040),
* data element: MEINS
MEINS_006(003),
* data element: MTPOS_MARA
MTPOS_MARA_007(004),
end of record.
DATA: FLNAME TYPE STRING.
*** End generated data section ***
DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
*** MESSAGE******
DATA: BEGIN OF MESSTAB OCCURS 0.
INCLUDE STRUCTURE BDCMSGCOLL.
DATA: MATNR TYPE MARA-MATNR,
END OF MESSTAB.
****END OF MESSAGE****
PARAMETERS: FILENAME TYPE RLGRAP-FILENAME.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILENAME.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = FILENAME.
start-of-selection.
*perform open_dataset using dataset.
perform open_group.
FLNAME = FILENAME.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = FLNAME
FILETYPE = 'DAT'
* HAS_FIELD_SEPARATOR = ' '
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* VIRUS_SCAN_PROFILE =
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
DATA_TAB = record
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.
LOOP AT record.
DATA:
CNT TYPE I.
CNT = CNT + 1.
REFRESH BDCDATA.
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-MATNR'
record-MATNR_001.
perform bdc_field using 'RMMG1-MBRSH'
record-MBRSH_002.
perform bdc_field using 'RMMG1-MTART'
record-MTART_003.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
record-KZSEL_01_004.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
record-MAKTX_005.
perform bdc_field using 'BDC_CURSOR'
'MARA-MEINS'.
perform bdc_field using 'MARA-MEINS'
record-MEINS_006.
perform bdc_field using 'MARA-MTPOS_MARA'
record-MTPOS_MARA_007.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
*perform bdc_transaction using 'MM01'.
CALL TRANSACTION 'MM01' USING BDCDATA
MODE 'N'
UPDATE 'A'
MESSAGES INTO MESSTAB.
READ TABLE MESSTAB INTO MESSTAB INDEX CNT.
IF MESSTAB-MSGTYP = 'E'.
MESSTAB-MATNR = RECORD-MATNR_001.
MODIFY MESSTAB INDEX CNT FROM MESSTAB. " TRANSPORTING MATNR.
ENDIF.
ENDLOOP.
FORM OPEN_GROUP.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING CLIENT = SY-MANDT
GROUP = 'MM01'
USER = SY-UNAME
KEEP = 'X'.
ENDFORM.
FORM BDC_INSERT.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'MM01'
* POST_LOCAL = NOVBLOCAL
* PRINTING = NOPRINT
* SIMUBATCH = ' '
* CTUPARAMS = ' '
TABLES
DYNPROTAB = 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.
ENDFORM.
END-OF-SELECTION.
LOOP AT MESSTAB.
IF MESSTAB-MSGTYP = 'E'.
WRITE:/ 'ERROR OCCURED ON MATNR = ',MESSTAB-MATNR , 'MESSAGE : MATNR ALREADY EXISTS IN MARA!!!'.
ENDIF.
ENDLOOP.
perform close_group.
*perform close_dataset using dataset.
*& Form close_group
* text
* --> p1 text
* <-- p2 text
FORM close_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.
ENDFORM. " close_group
*& Form bdc_dynpro
* text
* -->P_0270 text
* -->P_0271 text
FORM bdc_dynpro USING PROGRAM DYNPRO.
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM. " bdc_dynpro
*& Form bdc_field
* text
* -->P_0275 text
* -->P_0276 text
FORM bdc_field USING FNAM FVAL.
IF FVAL <> ' '.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
ENDIF.
ENDFORM. " bdc_field
*Text elements
* E00 Error opening dataset, return code:
* I01 Session name
* I02 Open session
* I03 Insert transaction
* I04 Close Session
* I05 Return code =
* I06 Error session created
* S01 Session name
* S02 User
* S03 Keep session
* S04 Lock date
* S05 Processing Mode
* S06 Update Mode
* S07 Generate session
* S08 Call transaction
* S09 Error sessn
* S10 Nodata indicator
* S11 Short log
HTH
Regards,
Dhruv Shah -
Need an RFC to upload the transaction FF_5 ( Standard or custom )
Hello Gurus,
I have a .940 file which should be uploaded in transaction FF_5.
I need an RFC or a BAPI, Either it may be a standard one or customized one.
The contents of the .940 is as follows ...
But in transaction FF_5 i want to give the following inputs
-- Import data -- should be checked ( I even dont know how to enable check boxes with the help of an RFC )
-- Electronic bank statement
-- statement file
-- XBLNR numeric interval _____ to _____
-- Print back statement -- Should be checked
-- print posting log -- Should be checked
-- Print stastics -- Should be checked
-- Seperate list -- Should be checked
I tried in some ways to achieve this, but i was not able to finish the process ...
So, Plz help me ....
Points ll be awarded for ur valuble replies without fail ....
Regards,
ChandrasekarHello,
What was your solution for this? We need the same functionality. So far we have a function that does a call transaction with a batch input map...
Kind regards,
J. -
- Differences between delta and full uploads of transactional data
Hi All,
This is with refrence to the loading transactional data into the cube.
I know that delta and full uploads of transactional data into the cube is done for the following reasons.
1. Delta upload allows change in transactional data (add/delete/modify) for the particular period selected but this is not the same in full upload.
2. Full upload takes less time compared to delta upload for the particular period.
Please let me know whether my understanding is correct. Otherwise, please explain these two concepts with examples taking loading transactional data into the cube.
Regards,
Ningarajuhi,
full upload is done to avoid more time to load the data .if u use initilallization then it will take more time to laod the same amount of data when compared to full load.
however your statement about the delta is correct.
u can perform delta only after sucessful initiallization.
so
1.first full load(to avoid more time0
2. inirtilallization with zero recored.
3. delta
regards -
Error in bdc uploading for transaction F-02
Hi all,
Iam uploading transactional data for the transaction F-02 using BDC call transaction.
I have recorded all the screens of F-02 and internal table with fields also declared.
While running the program, it is showing the error saying -- " Input value is longer than screen field "
In debugging, Iam getting all the data from flat file into the internal table.
Iam unable to identify where it has gone wrong.
Can anybody look into it.
Thanks and Regards,
Murali Krishna .TModerator message - Please search before asking - post locked
Rob -
Data Upload for Transaction KE51 through LSMW/BDC
Dear All,
I have a requirement where in i have to upload the customized data for Transaction KE51 and KS01 using LSMW or BDC or BAPI.
Please let me know the best possible procedure to achieve this task and how to do it. What are the validation we need to do etc.
If possible kindly send the screen shots or step by step procedure to do it.
Thanks in Advance.
Full Rewards if Usefull.
Regards
Vikas Badhan.Hi
Actually BDC call transaction methos s very to Upload.
u sit with ur functional consulant and recording ur Tcode.Because he oly know Functionalty based on that u have write ur program.
2. LSMW recording methos also very simply...Record ur Tcode and mapping ur fields orrectely.
Regards:
Prabu -
Uploading for Transaction IA05
Hi,
Does anybody have any idea what are the ways to upload data for transaction IA05 - General Task List. I understand there are LSMW direct inputs 470 and 490, but both of them lead to the same transaction IA01 i.e Equipment Task List.
I have created the BDC for this transaction but there is one problem with that the component data we want should be coming form BOM and while we do the transaction the component that getting selected are not from the BOM but of different category.
Can any please guide on this?
Regards
SaurabhThis requirement is like one-off. Would like to share with the community how it was eventually done as there is no standard functionality like BAPI or even BDC won't work.
This is done by updating the PLMZ table by calling the FM. Stringent validations will have to be performed before calling this FM as there can be a case where there is no Task list is created and there is a entry in PLMZ table which is for Components.
This function is used to record the changes done in IA06.
CALL FUNCTION 'CHANGEDOCUMENT_OPEN'
EXPORTING
objectclass = v_objectclass
objectid = v_objectid
planned_change_number = space
planned_or_real_changes = space
EXCEPTIONS
sequence_invalid = 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.
ENDIF.
v_count = text-075.
This is the main function module that will update the PLMZ table with data from it_plmzf*
CALL FUNCTION 'CM_VB_PLMZ_POST'
EXPORTING
aeb_kz = c_x
count_max = v_count
TABLES
planmz = it_plmzf
plmz_old = it_pplmz.
This function module is used to close the record log opened by 'CHANGEDOCUMENT_OPEN'.
CALL FUNCTION 'CHANGEDOCUMENT_CLOSE'
EXPORTING
date_of_change = sy-datum
objectclass = v_objectclass
objectid = v_objectid
tcode = 'IA06'
time_of_change = sy-uzeit
username = sy-uname
object_change_indicator = c_u
planned_or_real_changes = space
no_change_pointers = space
EXCEPTIONS
header_insert_failed = 1
no_position_inserted = 2
object_invalid = 3
open_missing = 4
position_insert_failed = 5
OTHERS = 6.
Call change document modules to record changes.
This will create the components by passing the task list number and operations.
Saurabh.
Edited by: Saurabh Maynil on Dec 29, 2009 8:00 PM
Edited by: Saurabh Maynil on Dec 29, 2009 8:02 PM -
" Thread in Bdc in uploading the data "
My scenario is to upload the data from the t-code WG21 . I HAVE WRITTEN A BDC PROGRAMME , HALF OF THE DATA IS UPLOADED , REMAINING DATA IS NOT UPLOADED . I AM GETTING THE ERROR MESSAGE AS FUNCTION CODE IS REQUIRED .
I AM SENDING MY BDC CODE AS AN EXAMPLE . CAN ANYBODY HELP ME IN SOLVING THE ISSUE.
report ZMC
no standard page heading line-size 255.
*include bdcrecx1.
INTERNAL TABLE DECLARATION ******
DATA : BEGIN OF ITAB OCCURS 0 ,
MATKL(9) TYPE C,
WGBEZ(20) TYPE C,
CLASS1(18) TYPE C,
WGBEZ60(60) TYPE C,
STATU(1) TYPE C,
MERKMA(1) TYPE C,
RELEV(01) TYPE C,
EINTRAG LIKE RMCLM-EINTRAG,
CLASS2(18) TYPE C,
END OF ITAB.
DATA: ITAB1 LIKE ITAB OCCURS 0 WITH HEADER LINE.
DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
DATA: messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
**AT SELECTION-SCREEN ON VALUE-REQUEST FOR file.
PERFORM GET_FILE.
SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: file TYPE rlgrap-filename OBLIGATORY,
mode TYPE ctu_params-dismode OBLIGATORY DEFAULT 'A'.
SELECTION-SCREEN : END OF BLOCK b1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR file.
PERFORM GET_FILE.
START-OF-SELECTION.
CALL FUNCTION 'UPLOAD'
EXPORTING
CODEPAGE = ' '
FILENAME = 'C:'
FILETYPE = 'DAT'
ITEM = ' '
FILEMASK_MASK = ' '
FILEMASK_TEXT = ' '
FILETYPE_NO_CHANGE = ' '
FILEMASK_ALL = ' '
FILETYPE_NO_SHOW = ' '
LINE_EXIT = ' '
USER_FORM = ' '
USER_PROG = ' '
SILENT = 'S'
IMPORTING
FILESIZE =
CANCEL =
ACT_FILENAME =
ACT_FILETYPE =
TABLES
DATA_TAB = ITAB
EXCEPTIONS
CONVERSION_ERROR = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 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.
perform open_group.
LOOP AT ITAB.
perform bdc_dynpro using 'SAPMWWG2' '1000'.
perform bdc_field using 'BDC_CURSOR'
'T023D-MATKL'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'T023D-MATKL'
ITAB-MATKL. "'120101114'.
perform bdc_dynpro using 'SAPMWWG2' '1100'.
perform bdc_field using 'BDC_CURSOR'
'WWGD-CLASS1'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'T023TD-WGBEZ'
ITAB-WGBEZ. "'non food category'.
perform bdc_field using 'T023TD-WGBEZ60'
ITAB-CLASS1. "'non food category'.
perform bdc_field using 'WWGD-CLASS1'
ITAB-WGBEZ60. "'nonfoods'.
perform bdc_dynpro using 'SAPMWWG2' '1100'.
perform bdc_field using 'BDC_CURSOR'
'T023TD-WGBEZ'.
perform bdc_field using 'BDC_OKCODE'
'=SAVE'.
CALL TRANSACTION 'WG21' USING bdcdata
MODE mode
UPDATE 'S'
MESSAGES INTO messtab.
CLEAR BDCDATA.
REFRESH BDCDATA.
PERFORM BDC_DYNPRO using 'SAPMWWG2' '1000'.
perform bdc_field using 'BDC_CURSOR'
'T023D-MATKL'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'T023D-MATKL'
ITAB-MATKL. "'120101114'.
PERform bdc_field using 'T023TD-WGBEZ'
ITAB-WGBEZ. "'non food category'.
perform bdc_field using 'T023TD-WGBEZ60'
ITAB-CLASS1. "'non food category'.
perform bdc_field using 'WWGD-CLASS1'
ITAB-WGBEZ60. "'NONFOODS'.
perform bdc_dynpro using 'SAPLCLMO' '7777'.
perform bdc_field using 'BDC_CURSOR'
'RMCLM-STATU'.
perform bdc_field using 'BDC_OKCODE'
'=SAVE'.
CALL TRANSACTION 'WG21' USING bdcdata
MODE mode
UPDATE 'S'
MESSAGES INTO messtab.
CLEAR BDCDATA.
REFRESH BDCDATA.
perform bdc_field using 'RMCLM-STATU'
ITAB-STATU. "'1'.
perform bdc_dynpro using 'SAPLCLMO' '7777'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BDC_CURSOR'
'RMCLM-RELEV(01)'.
perform bdc_field using 'RMCLM-MERKMA(01)'
ITAB-MERKMA. "'flavor'.
perform bdc_field using 'RMCLM-RELEV(01)'
ITAB-RELEV(01). "'1'.
perform bdc_dynpro using 'SAPLCLMO' '7777'.
perform bdc_field using 'BDC_OKCODE'
'/EENDE'.
perform bdc_dynpro using 'SAPLSPO1' '0100'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
perform bdc_dynpro using 'SAPLCLMO' '7777'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BDC_CURSOR'
'RMCLM-EINTRAG'.
perform bdc_field using 'RMCLM-EINTRAG'
ITAB-EINTRAG. "'1'.
perform bdc_dynpro using 'SAPMWWG2' '4000'.
perform bdc_field using 'BDC_CURSOR'
'WWGD-CLASS2'.
perform bdc_field using 'BDC_OKCODE'
'=BANL'.
perform bdc_field using 'T023D-MATKL'
ITAB-MATKL. "'120101114'.
perform bdc_field using 'WWGD-CLASS2'
ITAB-CLASS2. "'CHARAC'.
CALL TRANSACTION 'WG21' USING bdcdata
MODE mode
UPDATE 'S'
MESSAGES INTO messtab.
ENDLOOP.
perform close_group.
*& Form get_file
text
FORM GET_FILE.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = SYST-REPID
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'file '
FIELD_NAME = 'file '
STATIC = ' '
MASK = ' '
FILEOPERATION = 'R'
CHANGING
FILE_NAME = file
FILE_NAME = file
LOCATION_FLAG = 'P'
EXCEPTIONS
MASK_TOO_LONG = 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.
ENDIF.
ENDFORM. "GET_FILE
Start new 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.
IF FVAL <> NODATA.
CLEAR bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
APPEND bdcdata.
ENDIF.
ENDFORM. "BDC_FIELDHi,
Please post the question in the appropriate forum to get faster response.
-Vikram
Maybe you are looking for
-
Hello , Can anyone let me know how to trigger the END-of-page event in ALV using OOPs. Thanks in advance. Regards Jai
-
HI, I have created transport request for Bex Query. First time I created transport request , I collected all query and query elements apart from this two more additional components added to transport request ( No transport request open on that query,
-
/SAPAPO/SDORDER_DEL recommendations
Hello all, I'm performing the report /SAPAPO/SDORDER_DEL once a month with period of retention of 3 months due to degree performance problems with tables /SAPAPO/POSMAPN and /SAPAPO/SD_DOC. I didn't find any recommendation about SLS lifetime at APO s
-
When is the next generation iPhone going to be released?
When is the next generation iPhone going to be released?
-
Help it seems my Muvo2 .5 Gb is dead. It just turned off and no way to start it again. Tried to replace battery but no luck. Unfortunately I have used a car charger for my Muvo2. I think that might be the problem. Anybody any Idea? Thanks