Hi pls give names of some standard BDC program
thank you
ravi
BDC allows you to perform database updates in the background using standard SAP transactions.
The resultant entries will be as if the user had manually entered the data via SAP. This means
that you do not bypass any of the standard SAP consistency checks, authorisations etc.
There are two main methods of ABAP BDC, these are Call Transaction and Batch Input.
Other methods of update include Direct update, Idoc and BAPI.
e
Example program : 1
Report ZBDC_EXAMPLE *
*& Example BDC program, which updates net price of item 00010 of a *
*& particular Purchase order(EBELN). *
REPORT ZBDC_EXAMPLE NO STANDARD PAGE HEADING
LINE-SIZE 132.
* Data declaration
TABLES: ekko, ekpo.
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekko-ebeln,
waers TYPE ekko-waers,
netpr TYPE ekpo-netpr,
err_msg(73) TYPE c,
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko,
it_error TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_error TYPE t_ekko,
it_success TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_success TYPE t_ekko.
DATA: w_textout LIKE t100-text.
DATA: gd_update TYPE i,
gd_lines TYPE i.
*Used to store BDC data
DATA: BEGIN OF bdc_tab OCCURS 0.
INCLUDE STRUCTURE bdcdata.
DATA: END OF bdc_tab.
*Used to stores error information from CALL TRANSACTION Function Module
DATA: BEGIN OF messtab OCCURS 0.
INCLUDE STRUCTURE bdcmsgcoll.
DATA: END OF messtab.
*Screen declaration
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME
TITLE text-001. "Purchase order Num
SELECT-OPTIONS: so_ebeln FOR ekko-ebeln OBLIGATORY.
SELECTION-SCREEN END OF BLOCK block1.
SELECTION-SCREEN BEGIN OF BLOCK block2 WITH FRAME
TITLE text-002. "New NETPR value
PARAMETERS: p_newpr(14) TYPE c obligatory. "LIKE ekpo-netpr.
SELECTION-SCREEN END OF BLOCK block2.
*START-OF-SELECTION
START-OF-SELECTION.
* Retrieve data from Purchase order table(EKKO)
SELECT ekko~ebeln ekko~waers ekpo~netpr
INTO TABLE it_ekko
FROM ekko AS ekko INNER JOIN ekpo AS ekpo
ON ekpo~ebeln EQ ekko~ebeln
WHERE ekko~ebeln IN so_ebeln AND
ekpo~ebelp EQ '10'.
*END-OF-SELECTION
END-OF-SELECTION.
* Check data has been retrieved ready for processing
DESCRIBE TABLE it_ekko LINES gd_lines.
IF gd_lines LE 0.
* Display message if no data has been retrieved
MESSAGE i003(zp) WITH 'No Records Found'(001).
LEAVE TO SCREEN 0.
ELSE.
* Update Customer master data (instalment text)
LOOP AT it_ekko INTO wa_ekko.
PERFORM bdc_update.
ENDLOOP.
* Display message confirming number of records updated
IF gd_update GT 1.
MESSAGE i003(zp) WITH gd_update 'Records updated'(002).
ELSE.
MESSAGE i003(zp) WITH gd_update 'Record updated'(003).
ENDIF.
* Display Success Report
* Check Success table
DESCRIBE TABLE it_success LINES gd_lines.
IF gd_lines GT 0.
* Display result report column headings
PERFORM display_column_headings.
* Display result report
PERFORM display_report.
ENDIF.
* Display Error Report
* Check errors table
DESCRIBE TABLE it_error LINES gd_lines.
* If errors exist then display errors report
IF gd_lines GT 0.
* Display errors report
PERFORM display_error_headings.
PERFORM display_error_report.
ENDIF.
ENDIF.
*& Form DISPLAY_COLUMN_HEADINGS
* Display column headings
FORM display_column_headings.
WRITE:2 ' Success Report '(014) COLOR COL_POSITIVE.
SKIP.
WRITE:2 'The following records updated successfully:'(013).
WRITE:/ sy-uline(42).
FORMAT COLOR COL_HEADING.
WRITE:/ sy-vline,
(10) 'Purchase Order'(004), sy-vline,
(11) 'Old Netpr'(005), sy-vline,
(11) 'New Netpr'(006), sy-vline.
WRITE:/ sy-uline(42).
ENDFORM. " DISPLAY_COLUMN_HEADINGS
*& Form BDC_UPDATE
* Populate BDC table and call transaction ME22
FORM bdc_update.
PERFORM dynpro USING:
'X' 'SAPMM06E' '0105',
' ' 'BDC_CURSOR' 'RM06E-BSTNR',
' ' 'RM06E-BSTNR' wa_ekko-ebeln,
' ' 'BDC_OKCODE' '/00', "OK code
'X' 'SAPMM06E' '0120',
' ' 'BDC_CURSOR' 'EKPO-NETPR(01)',
' ' 'EKPO-NETPR(01)' p_newpr,
' ' 'BDC_OKCODE' '=BU'. "OK code
* Call transaction to update customer instalment text
CALL TRANSACTION 'ME22' USING bdc_tab MODE 'N' UPDATE 'S'
MESSAGES INTO messtab.
* Check if update was succesful
IF sy-subrc EQ 0.
ADD 1 TO gd_update.
APPEND wa_ekko TO it_success.
ELSE.
* Retrieve error messages displayed during BDC update
LOOP AT messtab WHERE msgtyp = 'E'.
* Builds actual message based on info returned from Call transaction
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = messtab-msgid
msgnr = messtab-msgnr
msgv1 = messtab-msgv1
msgv2 = messtab-msgv2
msgv3 = messtab-msgv3
msgv4 = messtab-msgv4
IMPORTING
message_text_output = w_textout.
ENDLOOP.
* Build error table ready for output
wa_error = wa_ekko.
wa_error-err_msg = w_textout.
APPEND wa_error TO it_error.
CLEAR: wa_error.
ENDIF.
* Clear bdc date table
CLEAR: bdc_tab.
REFRESH: bdc_tab.
ENDFORM. " BDC_UPDATE
* FORM DYNPRO *
* stores values to bdc table *
* --> DYNBEGIN *
* --> NAME *
* --> VALUE *
FORM dynpro USING dynbegin name value.
IF dynbegin = 'X'.
CLEAR bdc_tab.
MOVE: name TO bdc_tab-program,
value TO bdc_tab-dynpro,
'X' TO bdc_tab-dynbegin.
APPEND bdc_tab.
ELSE.
CLEAR bdc_tab.
MOVE: name TO bdc_tab-fnam,
value TO bdc_tab-fval.
APPEND bdc_tab.
ENDIF.
ENDFORM. " DYNPRO
*& Form DISPLAY_REPORT
* Display Report
FORM display_report.
FORMAT COLOR COL_NORMAL.
* Loop at data table
LOOP AT it_success INTO wa_success.
WRITE:/ sy-vline,
(10) wa_success-ebeln, sy-vline,
(11) wa_success-netpr CURRENCY wa_success-waers, sy-vline,
(11) p_newpr, sy-vline.
CLEAR: wa_success.
ENDLOOP.
WRITE:/ sy-uline(42).
REFRESH: it_success.
FORMAT COLOR COL_BACKGROUND.
ENDFORM. " DISPLAY_REPORT
*& Form DISPLAY_ERROR_REPORT
* Display error report data
FORM display_error_report.
LOOP AT it_error INTO wa_error.
WRITE:/ sy-vline,
(10) wa_error-ebeln, sy-vline,
(11) wa_error-netpr CURRENCY wa_error-waers, sy-vline,
(73) wa_error-err_msg, sy-vline.
ENDLOOP.
WRITE:/ sy-uline(104).
REFRESH: it_error.
ENDFORM. " DISPLAY_ERROR_REPORT
*& Form DISPLAY_ERROR_HEADINGS
* Display error report headings
FORM display_error_headings.
SKIP.
WRITE:2 ' Error Report '(007) COLOR COL_NEGATIVE.
SKIP.
WRITE:2 'The following records failed during update:'(008).
WRITE:/ sy-uline(104).
FORMAT COLOR COL_HEADING.
WRITE:/ sy-vline,
(10) 'Purchase Order'(009), sy-vline,
(11) 'Netpr'(010), sy-vline,
(73) 'Error Message'(012), sy-vline.
WRITE:/ sy-uline(104).
FORMAT COLOR COL_NORMAL.
ENDFORM. " DISPLAY_ERROR_HEADINGS
Example : 2
Goto transaction SHBD enter a recording name and specify the transaction code.
Enter the test data and save it , it will actomatically create a bdc program.
now select that recording name and click create program icon and specify the program name.
This is the program which was created using transaction SHDB for XD01.
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,
* data element: KUN16
KUNNR_001(016),
* data element: BUKRS
BUKRS_002(004),
* data element: VKORG
VKORG_003(004),
* data element: VTWEG
VTWEG_004(002),
* data element: SPART
SPART_005(002),
* data element: KTOKD
KTOKD_006(004),
* data element: ANRED
ANRED_007(015),
* data element: NAME1_GP
NAME1_008(035),
* data element: SORTL
SORTL_009(010),
* data element: NAME2_GP
NAME2_010(035),
* data element: STRAS_GP
STRAS_011(035),
* data element: PFACH
PFACH_012(010),
* data element: ORT01_GP
ORT01_013(035),
* data element: PSTLZ
PSTLZ_014(010),
* data element: ORT02_GP
ORT02_015(035),
* data element: PFORT_GP
PFORT_016(035),
* data element: PSTL2
PSTL2_017(010),
* data element: LAND1_GP
LAND1_018(003),
* data element: REGIO
REGIO_019(003),
* data element: SPRAS
SPRAS_020(002),
* data element: TELX1
TELX1_021(030),
* data element: TELF1
TELF1_022(016),
* data element: TELFX
TELFX_023(031),
* data element: TELF2
TELF2_024(016),
* data element: TELTX
TELTX_025(030),
* data element: TELBX
TELBX_026(015),
* data element: URL
KNURL_027(132),
* data element: STCD1
STCD1_028(016),
* data element: STCD2
STCD2_029(011),
* data element: BBBNR
BBBNR_030(007),
* data element: BBSNR
BBSNR_031(005),
* data element: BUBKZ
BUBKZ_032(001),
* data element: BRSCH
BRSCH_033(004),
* data element: LZONE
LZONE_034(010),
* data element: KUKLA
KUKLA_035(002),
* data element: BRSCH
BRSCH_036(004),
* data element: UMSA1
UMSA1_037(020),
* data element: UWAER
UWAER_038(005),
* data element: UMJAH
UMJAH_039(004),
* data element: JMZAH
JMZAH_040(006),
* data element: JMJAH
JMJAH_041(004),
* data element: BANKS
BANKS_01_042(003),
* data element: BANKK
BANKL_01_043(015),
* data element: BANKN
BANKN_01_044(018),
* data element: ABLAD
ABLAD_01_045(025),
* data element: KNKAL
KNFAK_01_046(002),
* data element: CIVVE
CIVVE_047(001),
* data element: ANRED_AP
ANRED_01_048(030),
* data element: ANRED_AP
ANRED_02_049(030),
* data element: NAMEV_VP
NAMEV_01_050(035),
* data element: NAMEV_VP
NAMEV_02_051(035),
* data element: NAME1_GP
NAME1_01_052(035),
* data element: NAME1_GP
NAME1_02_053(035),
* data element: TELF1
TELF1_01_054(016),
* data element: TELF1
TELF1_02_055(016),
* data element: ABTNR_PA
ABTNR_01_056(004),
* data element: ABTNR_PA
ABTNR_02_057(004),
* data element: AKONT
AKONT_058(010),
* data element: DZTERM
ZTERM_059(004),
* data element: MAHNA
MAHNA_060(004),
* data element: BZIRK
BZIRK_061(006),
* data element: AWAHR
AWAHR_062(003),
* data element: WAERS_V02D
WAERS_063(005),
* data element: KALKS
KALKS_064(001),
* data element: LPRIO
LPRIO_065(002),
* data element: KZAZU_D
KZAZU_066(001),
* data element: ANTLF
ANTLF_067(001),
* data element: PERFK
PERFK_068(002),
end of record.
*** End generated data section ***
start-of-selection.
perform open_dataset using dataset.
perform open_group.
do.
read dataset dataset into record.
if sy-subrc <> 0. exit. endif.
perform bdc_dynpro using 'SAPMF02D' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RF02D-KTOKD'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02D-KUNNR'
record-KUNNR_001.
perform bdc_field using 'RF02D-BUKRS'
record-BUKRS_002.
perform bdc_field using 'RF02D-VKORG'
record-VKORG_003.
perform bdc_field using 'RF02D-VTWEG'
record-VTWEG_004.
perform bdc_field using 'RF02D-SPART'
record-SPART_005.
perform bdc_field using 'RF02D-KTOKD'
record-KTOKD_006.
perform bdc_dynpro using 'SAPMF02D' '0110'.
perform bdc_field using 'BDC_CURSOR'
'KNA1-KNURL'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'KNA1-ANRED'
record-ANRED_007.
perform bdc_field using 'KNA1-NAME1'
record-NAME1_008.
perform bdc_field using 'KNA1-SORTL'
record-SORTL_009.
perform bdc_field using 'KNA1-NAME2'
record-NAME2_010.
perform bdc_field using 'KNA1-STRAS'
record-STRAS_011.
perform bdc_field using 'KNA1-PFACH'
record-PFACH_012.
perform bdc_field using 'KNA1-ORT01'
record-ORT01_013.
perform bdc_field using 'KNA1-PSTLZ'
record-PSTLZ_014.
perform bdc_field using 'KNA1-ORT02'
record-ORT02_015.
perform bdc_field using 'KNA1-PFORT'
record-PFORT_016.
perform bdc_field using 'KNA1-PSTL2'
record-PSTL2_017.
perform bdc_field using 'KNA1-LAND1'
record-LAND1_018.
perform bdc_field using 'KNA1-REGIO'
record-REGIO_019.
perform bdc_field using 'KNA1-SPRAS'
record-SPRAS_020.
perform bdc_field using 'KNA1-TELX1'
record-TELX1_021.
perform bdc_field using 'KNA1-TELF1'
record-TELF1_022.
perform bdc_field using 'KNA1-TELFX'
record-TELFX_023.
perform bdc_field using 'KNA1-TELF2'
record-TELF2_024.
perform bdc_field using 'KNA1-TELTX'
record-TELTX_025.
perform bdc_field using 'KNA1-TELBX'
record-TELBX_026.
perform bdc_field using 'KNA1-KNURL'
record-KNURL_027.
perform bdc_dynpro using 'SAPMF02D' '0120'.
perform bdc_field using 'BDC_CURSOR'
'KNA1-LZONE'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'KNA1-STCD1'
record-STCD1_028.
perform bdc_field using 'KNA1-STCD2'
record-STCD2_029.
perform bdc_field using 'KNA1-BBBNR'
record-BBBNR_030.
perform bdc_field using 'KNA1-BBSNR'
record-BBSNR_031.
perform bdc_field using 'KNA1-BUBKZ'
record-BUBKZ_032.
perform bdc_field using 'KNA1-BRSCH'
record-BRSCH_033.
perform bdc_field using 'KNA1-LZONE'
record-LZONE_034.
perform bdc_dynpro using 'SAPMF02D' '0125'.
perform bdc_field using 'BDC_CURSOR'
'KNA1-JMJAH'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'KNA1-KUKLA'
record-KUKLA_035.
perform bdc_field using 'KNA1-BRSCH'
record-BRSCH_036.
perform bdc_field using 'KNA1-UMSA1'
record-UMSA1_037.
perform bdc_field using 'KNA1-UWAER'
record-UWAER_038.
perform bdc_field using 'KNA1-UMJAH'
record-UMJAH_039.
perform bdc_field using 'KNA1-JMZAH'
record-JMZAH_040.
perform bdc_field using 'KNA1-JMJAH'
record-JMJAH_041.
perform bdc_dynpro using 'SAPMF02D' '0130'.
perform bdc_field using 'BDC_CURSOR'
'KNBK-BANKN(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'KNBK-BANKS(01)'
record-BANKS_01_042.
perform bdc_field using 'KNBK-BANKL(01)'
record-BANKL_01_043.
perform bdc_field using 'KNBK-BANKN(01)'
record-BANKN_01_044.
perform bdc_dynpro using 'SAPMF02D' '0130'.
perform bdc_field using 'BDC_CURSOR'
'KNBK-BANKS(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_dynpro using 'SAPMF02D' '0340'.
perform bdc_field using 'BDC_CURSOR'
'KNVA-KNFAK(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'KNVA-ABLAD(01)'
record-ABLAD_01_045.
perform bdc_field using 'KNVA-KNFAK(01)'
record-KNFAK_01_046.
perform bdc_dynpro using 'SAPMF02D' '0340'.
perform bdc_field using 'BDC_CURSOR'
'RF02D-KUNNR'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_dynpro using 'SAPMF02D' '0370'.
perform bdc_field using 'BDC_CURSOR'
'KNA1-CIVVE'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'KNA1-CIVVE'
record-CIVVE_047.
perform bdc_dynpro using 'SAPMF02D' '0360'.
perform bdc_field using 'BDC_CURSOR'
'KNVK-ABTNR(02)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'KNVK-ANRED(01)'
record-ANRED_01_048.
perform bdc_field using 'KNVK-ANRED(02)'
record-ANRED_02_049.
perform bdc_field using 'KNVK-NAMEV(01)'
record-NAMEV_01_050.
perform bdc_field using 'KNVK-NAMEV(02)'
record-NAMEV_02_051.
perform bdc_field using 'KNVK-NAME1(01)'
record-NAME1_01_052.
perform bdc_field using 'KNVK-NAME1(02)'
record-NAME1_02_053.
perform bdc_field using 'KNVK-TELF1(01)'
record-TELF1_01_054.
perform bdc_field using 'KNVK-TELF1(02)'
record-TELF1_02_055.
perform bdc_field using 'KNVK-ABTNR(01)'
record-ABTNR_01_056.
perform bdc_field using 'KNVK-ABTNR(02)'
record-ABTNR_02_057.
perform bdc_dynpro using 'SAPMF02D' '0360'.
perform bdc_field using 'BDC_CURSOR'
'KNVK-NAMEV(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_dynpro using 'SAPMF02D' '0210'.
perform bdc_field using 'BDC_CURSOR'
'KNB1-AKONT'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'KNB1-AKONT'
record-AKONT_058.
perform bdc_dynpro using 'SAPMF02D' '0215'.
perform bdc_field using 'BDC_CURSOR'
'KNB1-ZTERM'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'KNB1-ZTERM'
record-ZTERM_059.
perform bdc_dynpro using 'SAPMF02D' '0220'.
perform bdc_field using 'BDC_CURSOR'
'KNB5-MAHNA'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'KNB5-MAHNA'
record-MAHNA_060.
perform bdc_dynpro using 'SAPMF02D' '0230'.
perform bdc_field using 'BDC_CURSOR'
'KNB1-VRSNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02D' '0310'.
perform bdc_field using 'BDC_CURSOR'
'KNVV-WAERS'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'KNVV-BZIRK'
record-BZIRK_061.
perform bdc_field using 'KNVV-AWAHR'
record-AWAHR_062.
perform bdc_field using 'KNVV-WAERS'
record-WAERS_063.
perform bdc_field using 'KNVV-KALKS'
record-KALKS_064.
perform bdc_dynpro using 'SAPMF02D' '0315'.
perform bdc_field using 'BDC_CURSOR'
'KNVV-LPRIO'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'KNVV-LPRIO'
record-LPRIO_065.
perform bdc_field using 'KNVV-KZAZU'
record-KZAZU_066.
perform bdc_field using 'KNVV-ANTLF'
record-ANTLF_067.
perform bdc_dynpro using 'SAPMF02D' '0320'.
perform bdc_field using 'BDC_CURSOR'
'KNVV-PERFK'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'KNVV-PERFK'
record-PERFK_068.
perform bdc_dynpro using 'SAPMF02D' '1350'.
perform bdc_field using 'BDC_CURSOR'
'RF02D-KUNNR'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_dynpro using 'SAPMF02D' '0324'.
perform bdc_field using 'BDC_CURSOR'
'KNVP-PARVW(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_transaction using 'XD01'.
enddo.
perform close_group.
perform close_dataset using dataset.
gIRISH
Similar Messages
-
Standard BDC program used for FI
hi all ,
i would like to know the standard BDC program used in FI , like for tcode fb01 or somethings else.
Appreciate for any segguestion.
thanks and regards.hi siddu m
thanks for replay ,
i have anohter question
provided the transaction A was contianed in the first batch file,
and also contained in the second batch file , how the tcode treated as the duplicate posting ?
many thanks -
The standard BDC program for FI
hi all ,
i would like to know the standard BDC program usd in FI , like for tcode fb01 or somethings else.
Appreciate for any segguestion.
thanks and regards.thanks
another question,
how the fb01 check a duplicated entry?
any materials about this , i have seen that somewhere but can't remember it
thansk -
BAPI or FM or Standard BDC program for Production version creation (C223)
Hi All,
Is there BAPI or FM or Standard BDC program for Production version creation? Please help me.
Thanks & Regards
SanthoshHi,
Try this FM "CO_OCM_CREATE_PROD_VERSION"
Regards,
Smart -
During the material creation ,it is showing some error(bdc program)
hi expects,
during execution the program ,the material is created.but i am getting a message that field rmmg1-mbrsh(industrial sector) that "input value is longer than screen field.please help me solving this problem.REPORT ZMM_RDD0009_MATERIAL_CREATION .
structure declaration.
types : begin of ty_upload,
MAKTX TYPE MAKTX, "Material Description
WERKS TYPE WERKS, "PLANT
MTART TYPE MTART, "Material Type
MATKL TYPE MATKL, "Material Group
MEINS TYPE MEINS, "Base Unit of Measure
MFRPN TYPE MFRPN, "Manufacturing part number
SALK3 TYPE SALK3, "net amounting
PEINH TYPE PEINH, "price unit
VPRSV TYPE VPRSV, "price control indicator
BKLAS TYPE BKLAS, "valuattion class
end of ty_upload.
INTERNAL TABLE DECLARATION.
internal table for upload the data.
data:t_upload type standard table of ty_upload initial size 0,
*internal table for bdcdata.
t_bdcdata type standard table of bdcdata initial size 0 ,
*internal table for bdcmsgcoll.
t_bdcmsgcoll type standard table of bdcmsgcoll initial size 0,
t_error type standard table of ty_upload initial size 0,
WORK-AREA DECLARATION.
work-area for upload the data.
w_upload type ty_upload,
bdcdata type bdcdata,
work-area for bdcmsgcoll.
w_bdcmsg type bdcmsgcoll,
*global variable declaration.
g_message(70) type c.
*include bdcrecx1.
*start-of-selection.
start-of-selection.
call function 'GUI_UPLOAD'
exporting
filename = 'D:/MATERIAL.txt'
filetype = 'ASC'
has_field_separator = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
IMPORTING
FILELENGTH =
HEADER =
tables
data_tab = t_upload.
EXCEPTIONS
call function 'BDC_OPEN_GROUP'
exporting
client = sy-mandt
DEST = FILLER8
group = 'ERROR_MAT'
HOLDDATE = ''
KEEP = 'X'
user = sy-uname
RECORD = FILLER1
prog = sy-cprog.
loop at t_upload into w_upload.
refresh t_bdcdata.
*perform open_group.
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-MBRSH'
'W_UPLOAD-MBRSH'.
perform bdc_field using 'RMMG1-MTART'
'W_UPLOAD-MTART'.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(17)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
'X'.
perform bdc_field using 'MSICHTAUSW-KZSEL(04)'
'X'.
perform bdc_field using 'MSICHTAUSW-KZSEL(17)'
'X'.
perform bdc_dynpro using 'SAPLMGMM' '0080'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-WERKS'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'RMMG1-WERKS'
'W_UPLOAD-WERKS'.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
'W_UPLOAD-MAKTX'.
perform bdc_field using 'BDC_CURSOR'
'MARA-MATKL'.
perform bdc_field using 'MARA-MEINS'
'W_UPLOAD-MEINS'.
perform bdc_field using 'MARA-MATKL'
'W_UPLOAD-MATKL'.
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
'W_UPLOAD-MAKTX'.
perform bdc_field using 'MARA-MEINS'
'W_UPLOAD-MEINS'.
perform bdc_field using 'MARA-MATKL'
'W_UPLOAD-MATKL'.
perform bdc_field using 'BDC_CURSOR'
'MARA-MFRPN'.
perform bdc_field using 'MARA-MFRPN'
'W_UPLOAD-MFRPN'.
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
'W_UPLOAD-MAKTX'.
perform bdc_field using 'MARA-MEINS'
'W_UPLOAD-MEINS'.
perform bdc_field using 'BDC_CURSOR'
'MBEW-VERPR'.
perform bdc_field using 'MBEW-BKLAS'
'W_UPLOAD-BKLAS'.
perform bdc_field using 'MBEW-VPRSV'
'W_UPLOAD-VPRSV'.
perform bdc_field using 'MBEW-PEINH'
'1'.
perform bdc_field using 'MBEW-VERPR'
'W_UPLOAD-VERPR'.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
*perform bdc_transaction using 'MM01'.
*perform close_group.
call transaction 'MM01' using t_bdcdata mode 'N' update 'S'
messages into t_bdcmsgcoll.
if sy-subrc <> 0.
*append w_upload to t_error.
call function 'BDC_INSERT'
exporting
tcode = 'MM01'
tables
dynprotab = t_bdcdata.
endif.
clear w_bdcmsg.
read table t_bdcmsgcoll into w_bdcmsg index 1.
call function 'FORMAT_MESSAGE'
exporting
id = w_bdcmsg-msgid
lang = sy-langu
no = w_bdcmsg-msgnr
v1 = w_bdcmsg-msgv1
v2 = w_bdcmsg-msgv2
v3 = w_bdcmsg-msgv3
v4 = w_bdcmsg-msgv4
importing
msg = g_message
exceptions
not_found = 1
others = 2.
if sy-subrc = 0.
write:/ w_upload-maktx,'----', g_message.
refresh t_bdcmsgcoll.
endif.
endloop.
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 bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
append bdcdata to t_bdcdata.
clear bdcdata.
endform.
Insert field *
form bdc_field using fnam fval.
IF FVAL <> NODATA.
clear bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
append bdcdata to t_bdcdata.
clear bdcdata.
ENDIF.
endform.
FLAT FILE
MAT.DESCRIPTION PLANT MAT.TYPE MAT.GROUP UNIT
M 1000 ROH 001 KG
MANU.PART NET PRICE PRICE VALUATION
NUMBER AMOUNTING UNIT CONTROL CLASS
1 25 1 V 3000 -
Pls. give some suggestion on Subsequent Credit and debit note?
Dear Gurus,
Pls. give some suggestion on Subsequent Credit and debit note?
Regrds
ShikhaHi Sikha
We generaly use subsequent debit / credit to adjust invoice value without affecting Qty
Pls check notes supplied by SAP
A subsequent debit/credit arises if a transaction has already been settled, and a further invoice or credit memo is received afterwards.
A subsequent debit/credit changes the total invoice value of a purchase order item; the total invoice quantity remains unchanged. Therefore, only a value-based update of the purchasing transaction takes place. There is no quantity-based update.
You must enter an invoice as a subsequent debit if a purchase order item has already been invoiced and further costs are incurred. (Example: A vendor has inadvertently invoiced you at too low a price and then sends a second invoice for the difference.)
You must enter a credit memo as a subsequent credit if a purchase order item was invoiced at too high a price and now you have received a credit memo. (Example: A vendor has inadvertently invoiced you at too high a price and then sends a credit memo for the difference.)
If you enter a subsequent debit/credit, the system suggests the entire invoiced quantity, but no value. The maximum quantity that you can subsequently debit or credit is the quantity that has already been invoiced.
You can only enter a subsequent debit/credit for a purchase order item if an invoice has already been posted for that item.
A subsequent debit/credit cannot refer to a particular invoice.
Subsequent debits and credits are listed separately in the PO history
Typical example is like
suppose vendor has overcharged u for perticular PO and afterward he want to correct it
In such scenario u can post subsequent debit to correct PO without affecting Qty. field
<b>Reward if usefull</b>
Vishal.. -
Hello ! pls give some ti[ps how to use bapi's for data uploading?
hello !
pls give some ti[ps how to use bapi's for data uploading?
regards,
ArjunHi,
See the below report extract:
where it_data is having uploaded data.
LOOP AT<b> it_data</b> INTO wa_data.
line_count = sy-tabix.
"Date Validation
CONCATENATE wa_data-uplft_date4(4) wa_data-uplft_date2(2) wa_data-uplft_date+0(2)
INTO wa_data-uplft_date.
"READ TABLE it_ekko INTO wa_ekko WITH KEY lifnr = wa_data-vendor.
LOOP AT it_ekko_temp INTO wa_ekko_temp WHERE lifnr = wa_data-vendor.
IF wa_ekko_temp-kdatb <= wa_data-uplft_date AND wa_ekko_temp-kdate >= wa_data-uplft_date.
MOVE-CORRESPONDING wa_ekko_temp TO wa_ekko.
APPEND wa_ekko TO it_ekko.
ENDIF.
ENDLOOP.
"IF sy-subrc = 0 AND wa_ekko-kdatb <= wa_data-uplft_date AND wa_ekko-kdate >= wa_data-uplft_date.
LOOP AT it_ekko INTO wa_ekko.
wa_data_header-pstng_date = wa_data-uplft_date.
wa_data_header-doc_date = sy-datum.
wa_data_header-bill_of_lading = wa_data-bill_of_lad.
wa_data_header-ref_doc_no = wa_data-del_no.
CONCATENATE wa_data-header_text1 '-'
wa_data-header_text2 '-'
wa_data-header_text3 '-'
wa_data-header_text4
into wa_data_header-HEADER_TXT.
IF wa_data-indicator = 'Y'.
wa_data_item-material = '000000000000200568'.
ELSE.
wa_data_item-material = '000000000000200566'.
ENDIF.
LOOP AT it_ekpo INTO wa_ekpo WHERE ebeln = wa_ekko-ebeln AND matnr = wa_data_item-material.
"Collect Item Level Data
wa_data_item-plant = '1000'.
wa_data_item-stge_loc = '1001'.
wa_data_item-move_type = '101'.
wa_data_item-vendor = wa_data-vendor.
wa_data-qnty = wa_data-qnty / 1000.
wa_data_item-entry_qnt = wa_data-qnty.
wa_data_item-po_pr_qnt = wa_data-qnty.
wa_data_item-entry_uom = 'KL'.
wa_data_item-entry_uom_iso = 'KL'.
wa_data_item-orderpr_un = 'KL'.
wa_data_item-orderpr_un_iso = 'KL'.
wa_data_item-no_more_gr = 'X'.
wa_data_item-po_number = wa_ekpo-ebeln.
wa_data_item-po_item = wa_ekpo-ebelp.
wa_data_item-unload_pt = wa_data-unload_pt.
wa_data_item-mvt_ind = 'B'.
APPEND wa_data_item TO it_data_item.
CLEAR wa_data_item.
ENDLOOP.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = wa_data_header
goodsmvt_code = goodsmvt_code
testrun = 'X'
TABLES
goodsmvt_item = it_data_item
return = return.
READ TABLE return INTO wa_return WITH KEY type = 'S'.
IF sy-subrc <> 0.
DESCRIBE TABLE return LINES sy-tfill.
IF sy-tfill = 0.
CALL FUNCTION <b>'BAPI_GOODSMVT_CREATE'</b>
EXPORTING
goodsmvt_header = wa_data_header
goodsmvt_code = goodsmvt_code
testrun = ' '
TABLES
goodsmvt_item = it_data_item
return = return.
CALL FUNCTION <b>'BAPI_TRANSACTION_COMMIT'</b>
EXPORTING
WAIT = 'X'
IMPORTING
RETURN =
ENDIF.
ENDIF.
LOOP AT return INTO wa_return.
WRITE: 'Messsage TYPE ', wa_return-type,
/,'ID ', wa_return-id,
/, 'Number ', wa_return-number,
/, 'Message ', wa_return-message,
/, 'Long Text ', wa_return-message_v1,
wa_return-message_v2,
wa_return-message_v3,
wa_return-message_v4,
/, 'Failed at line', line_count.
ENDLOOP.
CLEAR: wa_ekko, wa_ekpo, wa_data, it_data_item[], wa_data_header.
ENDLOOP.
Reward if useful! -
Pls give some shell scripting for sql/plsql
pls give some shell scripting for sql/plsql
794244 wrote:
pls give some shell scripting for sql/plsqlNeither SQL or PL/SQL are shell script languages. Both are server side languages that executes inside an Oracle database server process.
This is an important concept to understand when using SQL*Plus for example to "script" interaction with an Oracle database. -
Difference between L1,L2 and L3 support,pls give me some examples
Hi,
can u please tell me the difference between L1,L2 AND L3 SUPPORT.pls give me some examplesknowledgespring wrote:
People keep ask which level support are you supporting..? how do we answer to these questions in interview.. could one please provide info on this.
thank you in advance.Since the terms themselves can be defined differently by different organizations, you'll have to ask the interviewer how HE defines those terms. Once you know that you should know the answer. In asking him how he defines them, you might explain that you are asking because you know the terms can mean different things to different organizations. -
Hi I am having a problem to delete call log in iPhone 3GS from last 1 month, I have restore iPhone many times but it doesn't works, pls give me a solution , whenever I try to delete call log it's hang for some time, pls tell me how to restore call delete option
jsavage9621,
It pains me to hear about your experience with the Home Phone Connect. This device usually works seamlessly and is a great alternative to a landline phone. It sounds like we've done our fair share of work on your account here. I'm going to go ahead and send you a Private Message so that we can access your account and review any open tickets for you. I look forward to speaking with you.
TrevorC_VZW
Follow us on Twitter @VZWSupport -
HI all pls give me diff btwn upload ws_upload and GUI Upload
HI All,
pls give me difference between
upload
ws_upload and
GUI Upload
Thanks & regards .
Bharat KumarHi,
WS_* Function modules are replaced by GUI_* FMs from 4.7 SAP version.
GUI_* modules have additional parameters when compared with WS_* FMs.
Both FM are used for uploading data .
But ws_upload is obsolete now .
WS_UPLOAD and WS_DOWNLOAD, the function modules used until now are not part of the standard set of ABAP commands. They are used to display the file interface on the presentation server. WS_UPLOAD and WS_DOWNLOAD are not compatible with USs and have been replaced by GUI_UPLOAD and GUI_DOWNLOAD.
The new function modules, GUI_UPLOAD and GUI_DOWNLOAD, have an interface that also allows you to write Unicode format to the local hard drive. For a description of these interfaces, refer to the documentation for each function module, available under SAP Easy Access " Development " Function Builder " Goto " Documentation.
WS_UPLOAD, GUI_UPLOAD FMs are used in BDCs.
WS_UPLOAD loads files from the Presentation Server to Internal ABAP Tables.
This is used upto SAP 4.6 version.
GUI_UPLOAD is used to loads a file from the PC to the server. The data can be
transferred in binary or text format. Numbers and data fields can be
interpreted according to the user settings.
You can check this for some info
http://help.sap.com/saphelp_erp2005/helpdata/en/79/c554a3b3dc11d5993800508b6b8b11/frameset.htm
http://www.sapdevelopment.co.uk/file/file_otherpc.htm
Regards,
Priyanka. -
Give a simple example of BDC using Recording method
give the various steps ...
For a BDC upload you need to write a program which created BDC sessions.
Steps:
1. Work out the transaction you would use to create the data manually.
2. Use transaction SHDB to record the creation of one material master data.
Click the New recording button or the Menu - Recording - Create
3. Save the recording, and then go back a screen and go to the overview.
4. Select the recording and click on Edit - Create Program. Give the program a Z name, and select transfer from recording.
5. Edit the program. You will see that all the data you entered is hard-coded into the program. You need to make the following changes:
5.1 After the start-of-selection, Call ws_upload to upload the file (the excel file needs to be saved as TAB separated).
5.2 After the open-group, Loop on the uploaded data. For each line, perform validation checks on the data, then modify the perform bdc_field commands to use the file data.
5.3. After perform bdc_transaction, add the endloop.
Execute the program. It will have options to create a batch session or to process directly.
These are all my finds . Might be it will be useful to you.
Direct call of transactions, session handling:
/nxxxx This terminates the current transaction, and starts transaction xxxx
/n This terminates the transaction. This generally corresponds to pressing F15 to go back.
/nend This termiantes all separate sessions and logs off (corresponds to System - Logoff).
/nex This terminates all separate sessions and logs off immediately (without any warning!).
/oxxxx This opens a new session and starts transaction xxxx in This session.
/o This lists existing sessions and allows deletion or opening of a new session.
/i This terminates the current session (corresponds to System End
/i1, /i2,... This terminates the session with the number given.
.xyzw Fast path: 'xyzw' refers to the underlined letters in the menus. This type of navigation is uncommon and is provided more for emergencies (such as a defective mouse).
Batch
The following commands can be entered in correction mode ('Process in foreground' or 'Display errors only') when processing a batch input session:
/n This terminates the current batch input transaction and characterizes it as
/bdel This deletes the current batch input transaction.
/bend This terminates batch input processing and sets the session to Failed
/bda This switches from Display errors only to Process in foreground
/bde This switches from Process in foreground to Display errors only
ABAP/4
/h This switches into debugging mode.
/hs This switches into debugging mode and activates the debugging of system functions.
Buffer
WARNING: Resetting buffers can significantly change the performance of the entire system for a long time.
It should therefore only be used where there is a good reason tdso. As of release 3.0B system administator authorization is required (authorization object (S_ADMI_FCD). The action is noted in the system log.
/$SYNC This resets all buffers of the application server
/$CUA This resets the CUA buffer of the application server
/$TAB This resets the TABLE buffers of the application server
/$NAM This resets the nametab buffer of the application server
/$DYNP This resets the screen buffer of the application server
SHDB recording helps you to identify the desired screen flow. It shows details like screen sequence, screen nos, screen element names and required user command keys. This all helps while designing / coding a BDC flow for a transaction in the custom program. If you have any more questions or if you are not clear about SHDB, please check this links -
http://www.planetsap.com/Tips_and_Tricks.htm
http://www.itcserver.com/blog/2006/07/12/shdb-the-transaction-recorder/
Direct Input.
Without calling the screens but all the validations should be done and only for master datas upload.
Direct Input method:
1. Only for error free datas and also master data
updation.
2. It will directly updates the database table. No
screens involved.
3. Transaction BMVO or Program RBMVSHOW has been
used.
BDC(Batch Input Session):
1. Screens will be called programmatically.
2. First sessions will be created then we'll run the seesions in SM35 transaction.
3.Synchronous database update. After the processing the session only database update will occur.
For BDC:
http://myweb.dal.ca/hchinni/sap/bdc_home.htm
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/bdc&
http://www.sap-img.com/abap/learning-bdc-programming.htm
http://www.sapdevelopment.co.uk/bdc/bdchome.htm
http://www.sap-img.com/abap/difference-between-batch-input-and-call-transaction-in-bdc.htm
http://help.sap.com/saphelp_47x200/helpdata/en/69/c250684ba111d189750000e8322d00/frameset.htm
http://www.sapbrain.com/TUTORIALS/TECHNICAL/BDC_tutorial.html
Check these link:
http://www.sap-img.com/abap/difference-between-batch-input-and-call-transaction-in-bdc.htm
http://www.sap-img.com/abap/question-about-bdc-program.htm
http://www.itcserver.com/blog/2006/06/30/batch-input-vs-call-transaction/
http://www.planetsap.com/bdc_main_page.htm
call Transaction or session method ?
Check this sample one
******Internal Table for Header Data.
TYPES : BEGIN OF type_header,
kschl LIKE konv-kschl,
vkorg LIKE vbak-vkorg,
vtweg LIKE komg-spart,
matnr LIKE mvke-matnr,
kbetr(11) TYPE c,
datab(10) TYPE c,
datbi(10) TYPE c,
END OF type_header.
****Internal Table for Item Level.
TYPES : BEGIN OF type_item,
kschl LIKE konv-kschl,
vkorg LIKE vbak-vkorg,
vtweg LIKE komg-spart,
matnr LIKE mvke-matnr,
kbetr(11) TYPE c,
datab(10) TYPE c,
datbi(10) TYPE c,
END OF type_item.
******Error Table For not found in MVKE.
TYPES : BEGIN OF type_error ,
kschl LIKE konv-kschl,
vkorg LIKE vbak-vkorg,
vtweg LIKE komg-spart,
matnr LIKE mvke-matnr,
kbetr LIKE konp-kbetr,
datab(10) TYPE c,
datbi(10) TYPE c,
text(100) TYPE c,
END OF type_error.
****For error Messages
TYPES : BEGIN OF type_mtab,
matnr LIKE mara-matnr,
msgtyp LIKE bdcmsgcoll-msgtyp,
msgid LIKE bdcmsgcoll-msgid,
msgnr LIKE bdcmsgcoll-msgnr,
text(100) TYPE c,
END OF type_mtab.
****Internal Table
TYPES: BEGIN OF type_mvke,
matnr LIKE mvke-matnr,
vkorg LIKE mvke-vkorg,
vtweg LIKE mvke-vtweg,
END OF type_mvke.
****Internal Table
TYPES : BEGIN OF type_tvkov,
vkorg LIKE tvkov-vkorg,
vtweg LIKE tvkov-vtweg,
END OF type_tvkov.
Declaring Internal Tables
DATA : t_header TYPE STANDARD TABLE OF type_header,
t_item TYPE STANDARD TABLE OF type_item,
t_mvke TYPE STANDARD TABLE OF type_mvke,
t_tvkov TYPE STANDARD TABLE OF type_tvkov,
t_error TYPE STANDARD TABLE OF type_error,
t_mtab TYPE STANDARD TABLE OF type_mtab.
Work Area Declaration.
DATA : wa_header LIKE LINE OF t_header,
wa_item LIKE LINE OF t_item,
wa_error LIKE LINE OF t_error,
wa_mtab LIKE LINE OF t_mtab,
wa_tvkov LIKE LINE OF t_tvkov,
wa_mvke LIKE LINE OF t_mvke.
*Rows for Table with Excel Data*******
DATA: t_xls_file LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE.
***Constant.
DATA : c_params LIKE ctu_params.
DATA : c_ans(1) TYPE c.
DATA : v_count(4) TYPE c. " To show No.of records
DATA : bdctab LIKE bdcdata OCCURS 10 WITH HEADER LINE. " BDCDATA
DATA : tmess_mtab LIKE bdcmsgcoll OCCURS 10 WITH HEADER LINE.
SELECTION SCREEN
SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS : p_fname LIKE rlgrap-filename OBLIGATORY.
SELECTION-SCREEN : END OF BLOCK b1.
END OF SELECTION SCREEN.
DATA : repid LIKE sy-repid.
DATA : v_matnr(50) TYPE c, "used for line items
v_kbetr(50) TYPE c, "used for line items
v_dat1(50) TYPE c, "used for line items
v_dat(50) TYPE c. "used for line items
DATA : v_lindx(5) TYPE n ,"index counter for first 14 records.
v_lindx1(5) TYPE n VALUE '01', "index counter for 13 records.
v_item(5) TYPE c, "To increment the line index
v_pgedwn2 TYPE i . "For Pagedown Counter
DATA: v_currentrow TYPE i. "For Current Row
DATA v_bdc(50) TYPE c." Text to apper in Confrim POPUP Window.
************AT SELECTION-SCREEN
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname.
PERFORM get_filename USING p_fname.
*************START-OF-SELECTION
START-OF-SELECTION.
******Values for Ctu_params to Transaction
c_params-defsize = 'X'.
c_params-dismode = 'N'.
c_params-updmode = 'S'.
******Refresh
PERFORM f_refresh.
*********To upload File.
PERFORM upload_file.
****User Confrimation only BDC will Process
IF c_ans = '1'.
*** BDC Process.
PERFORM read_data.
ELSE.
FORMAT COLOR 3 INTENSIFIED .
WRITE:/ 'Selected not to Process the Upload'.
EXIT.
ENDIF.
******On completion of Process Refresh the Internal Table
REFRESH : t_xls_file,
t_header,
t_item,
t_mvke,
t_tvkov.
CLEAR : t_xls_file,
wa_header,
wa_item,
wa_mvke,
wa_tvkov.
***********Display Messages
WRITE : /01 'Status',19 'Status Text'.
WRITE AT 0(150) sy-uline.
LOOP AT t_mtab INTO wa_mtab.
WRITE :/01 wa_mtab-msgtyp,19 wa_mtab-text.
ENDLOOP.
SKIP 2.
SORT t_error BY matnr.
WRITE AT 0(150) sy-uline.
WRITE 'ERROR MESSAGES'.
WRITE AT 0(150) sy-uline.
WRITE :/01 'Material.No',20 'Status Text'.
WRITE AT 0(150) sy-uline.
LOOP AT t_error INTO wa_error WHERE matnr NE ' '.
WRITE:/01 wa_error-matnr,20 wa_error-text.
ENDLOOP.
*& Form get_filename
text
-->P_FILENAME text
FORM get_filename USING p_fname.
*****To read the file from Presentation Server
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
program_name = repid
dynpro_number ! ; = syst-dynnr
field_name = p_fname
STATIC = ' '
mask = '*.XLS'
CHANGING
file_name = p_fname
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_filename
*& Form upload_file
text
--> p1 text
<-- p2 text
FORM upload_file.
DATA : frow VALUE 2 TYPE i,
fcol VALUE 1 TYPE i,
erow VALUE 10000 TYPE i,
ecol VALUE 7 TYPE i,
ecol1 VALUE 1 TYPE i,
c_col1 TYPE i VALUE '0001',
c_col2 TYPE i VALUE '0002',
c_col3 TYPE i VALUE '0003',
&nb! sp; c_col4 TYPE i VALUE '0004',
c_col5 TYPE i VALUE '0005',
c_col6 TYPE i VALUE '0006',
c_col7 TYPE i VALUE '0007'.
***FM used to UPLOAD data from Flat file
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_fname
i_begin_col = fcol
i_begin_row = frow
i_end_col = ecol
i_end_row = erow
TABLES
intern = t_xls_file
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE e000.
ENDIF.
****T_XLS_FILE is initial, stop the process & throw message
IF t_xls_file[] IS INITIAL.
FORMAT COLOR 6 ON INTENSIFIED ON.
WRITE:/ 'No Data Exists '.
FORMAT COLOR OFF INTENSIFIED OFF.
STOP.
ELSE.
Sort table by rows and colums
SORT t_xls_file BY row col.
Get first row retrieved
READ TABLE t_xls_file INDEX 1.
Set first row retrieved to current row
v_currentrow = t_xls_file-row.
**Loop to move data in internal Table
LOOP AT t_xls_file .
Reset values for next row
IF t_xls_file-row NE v_currentrow.
APPEND wa_header TO t_header.
CLEAR wa_header.
v_currentrow = t_xls_file-row.
ENDIF.
CASE t_xls_file-col.
WHEN c_col1. "Kschl
wa_header-kschl = t_xls_file-value.
WHEN c_col2. "Vkorg
wa_header-vkorg = t_xls_file-value.
WHEN c_col3. "vtweg
wa_header-vtweg = t_xls_file-value.
WHEN c_col4. "Matnr
wa_header-matnr = t_xls_file-value.
WHEN c_col5. "Kbetr
wa_header-kbetr = t_xls_file-value.
WHEN c_col6. "FROm
wa_header-datab = t_xls_file-value.
WHEN c_col7. "TO
wa_header-datbi = t_xls_file-value.
ENDCASE.
ENDLOOP.
APPEND wa_header TO t_header.
CLEAR wa_header.
ENDIF.
****To process the data
PERFORM f_process.
ENDFORM. " upload_file
*& Form READ_DATA
text
--> p1 text
<-- p2 text
FORM read_data.
****To make Uniq Records in Header Level
SORT t_header BY kschl vkorg vtweg.
DELETE ADJACENT DUPLICATES FROM t_header COMPARING
kschl vkorg vtweg .
SORT t_item BY vkorg vtweg matnr.
DATA : wa1_item TYPE type_item.
DATA : l_cnt TYPE i.
DATA : flag(1) TYPE c. "to process the Line item.
***Looping Header Table.
LOOP AT t_header INTO wa_header.
PERFORM bdc_dynpro US! ING 'SAPMV13A' '0100'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RV13A-KSCHL'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ANTA'.
PERFORM bdc_field USING 'RV13A-KSCHL'
wa_header-kschl.
PERFORM bdc_dynpro USING 'SAPLV14A' '0100'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RV130-SELKZ(03)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=WEIT'.
PERFORM bdc_field USING 'RV130-SELKZ(03)'
'X'.
PERFORM bdc_dynpro USING 'SAPMV13A' '1004'.
PERFORM bdc_field USING 'BDC_CURSOR'
'KOMG-VKORG'.
PERFORM bdc_field USING 'KOMG-VKORG'
wa_header-vkorg.
PERFORM bdc_field USING 'KOMG-VTWEG'
wa_header-vtweg.
****To handle Line Items.
LOOP AT t_item INTO wa1_item WHERE vkorg = wa_header-vkorg AND
vtweg = wa_header-vtweg.
wa_item = wa1_item.
******Flag Set only After processing first 14 records .
IF flag = ' '.
v_lindx = v_lindx + 01.
SHIFT v_lindx LEFT DELETING LEADING '0'.
v_item = v_lindx .
CONCATENATE 'KOMG-MATNR(' v_item ')' INTO v_matnr.
PERFORM bdc_field USING v_matnr
wa_item-matnr.
CONCATENATE 'KONP-KBETR(' v_item ')' INTO v_kbetr.
PERFORM bdc_field USING v_kbetr
wa_item-kbetr.
CONCATENATE 'RV13A-DATAB(' v_item ')' INTO v_dat.
PERFORM bdc_field USING v_dat
wa_item-datab.
CONCATENATE 'RV13A-DATBI(' v_item ')' INTO v_dat1.
PERFORM bdc_field USING v_dat1
wa_item-datbi.
IF v_item = 14.
flag = 'X'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=P+'.
PERFORM bdc_dynpro USING 'SAPMV13A' '1004'.
CLEAR v_lindx.
CLEAR v_item.
CONTINUE.
ENDIF.
ENDIF.
***Flag is Set after Processing of 14 records.
TO process rest of Records
IF flag = 'X'.
v_pgedwn2 = v_pgedwn2 + 1.
v_lindx1 = v_lindx1 + 01.
SHIFT v_lindx1 LEFT DE! LETING LEADING '0'.
v_item = v_lindx1 .
CONCATENATE 'KOMG-MATNR(' v_it! em ')' INTO v_matnr.
PERFORM bdc_field USING v_matnr
wa_item-matnr.
CONCATENATE 'KONP-KBETR(' v_item ')' INTO v_kbetr.
PERFORM bdc_field USING v_kbetr
wa_item-kbetr.
CONCATENATE 'RV13A-DATAB(' v_item ')' INTO v_dat.
PERFORM bdc_field USING v_dat
wa_item-datab.
CONCATENATE 'RV13A-DATBI(' v_item ')' INTO v_dat1.
PERFORM bdc_field USING v_dat1
wa_item-datbi.
IF v_pgedwn2 = 13.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=P+'.
PERFORM bdc_dynpro USING 'SAPMV13A' '1004'.
v_pgedwn2 = 0.
v_lindx1 = 1.
CLEAR v_item.
CONTINUE.
ENDIF.
ENDIF.
ENDLOOP.
PERFORM bdc_field USING 'BDC_OKCODE'
'=SICH'.
Calling Transaction after Processing All items.
CALL TRANSACTION 'VK11' USING bdctab
OPTIONS FROM c_params MESSAGES INTO tmess_mtab.
REFRESH bdctab.
CLEAR : bdctab.
CLEAR : wa_item.
CLEAR : wa1_item.
CLEAR : wa_header.
CLEAR : l_cnt.
CLEAR : v_lindx1.
CLEAR: v_pgedwn2,v_lindx.
LOOP AT tmess_mtab .
l_cnt = l_cnt + 1.
READ TABLE t_item INTO wa_item INDEX l_cnt .
CALL FUNCTION 'MASS_MESSAGE_GET' "To get the Message Text
EXPORTING
arbgb = tmess_mtab-msgid
msgnr = tmess_mtab-msgnr
msgv1 = tmess_mtab-msgv1
msgv2 = tmess_mtab-msgv2
msgv3 = tmess_mtab-msgv3
msgv4 ! = tmess_mtab-msgv4
IMPORTING
msgtext = wa_mtab-text
EXCEPTIONS
message_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
wa_mtab-matnr = wa_item-matnr.
wa_mtab-msgtyp = tmess_mtab-msgtyp.
wa_mtab-msgid = tmess_mtab-msgid.
wa_mtab-msgn! r = tmess_mtab-msgnr.
APPEND wa_mtab TO t_mtab.
CLEAR wa_mtab-text.
CLEAR wa_item.
ENDLOOP.
ENDLOOP.
ENDFORM. " READ_DATA
*& Form BDC_DYNPRO
text
-->P_0300 text
-->P_0301 text
Start new screen *
FORM bdc_dynpro USING program dynpro.
CLEAR bdctab.
bdctab-program = program.
bdctab-dynpro = dynpro.
bdctab-dynbegin = 'X'.
APPEND bdctab.
ENDFORM. " BDC_DYNPRO
*& Form BDC_FIELD
text
-->P_0305 text
-->P_WA_HEADER_KSCHL text
Insert field *
FORM bdc_field USING fnam fval.
CLEAR bdctab.
bdctab-fnam = fnam.
bdctab-fval = fval.
APPEND bdctab.
ENDFORM. " BDC_FIELD
*& Form bdc_trc_ansaction
text
-->P_0527 text
*& Form f_Process
text
--> p1 text
<-- p2 text
FORM f_process.
DATA : l_todate(12) TYPE c,
l_frdate(12) TYPE c.
***Select for all entries of material in Header "Flat File Materials".
IF NOT t_header[] IS INITIAL.
SELECT matnr vkorg vtweg FROM mvke INTO TABLE t_mvke FOR ALL ENTRIES
IN t_header WHERE matnr = t_header-matnr AND
vkorg = t_header-vkorg AND
vtweg = t_header-vtweg.
ENDIF.
*********select Sales.org & Dist.channel.
IF NOT t_header[] IS INITIAL.
SELECT vkorg vtweg FROM tvkov INTO TABLE t_tvkov FOR ALL ENTRIES IN
t_header WHERE vkorg = t_header-vkorg
AND vtweg = t_header-vtweg.
ENDIF.
***Checking for material in Sales Master Table
SORT t_mvke BY matnr vkorg vtweg.
SORT t_tvkov BY vkorg vtweg.
LOOP AT t_header INTO wa_header.
READ TABLE t_mvke INTO wa_mvke WITH KEY matnr = wa_header-matnr
vkorg = wa_header-vkorg
! ; vtweg = wa_header-vtweg BINARY SEARCH.
IF sy-subrc <> 0.
wa_error = wa_header.
&nb! sp; MOVE text-011 TO wa_error-text.
APPEND wa_error TO t_error.
DELETE TABLE t_header FROM wa_header.
ELSE.
********Date Validations
IF ( wa_header-datab NE ' ! ; ' AND wa_header-datbi NE ' ' ) .
l_todate = wa_header-datab.
l_frdate = wa_header-datbi.
REPLACE '.' INTO l_toda! te WITH ''.
REPLACE '.' INTO l_todate WITH ''.
CONDENSE l_todate NO-GAPS.
REPLACE '.' INTO l_frdate WITH ''.
REPLACE '.' INTO l_frdate WITH ''.
CONDENSE l_frdate NO-GAPS.
IF l_frdate < l_todate.
wa_error = wa_header .
MOVE text-012 TO wa_error-text.
APPEND wa_error TO t_error.
DELETE TABLE t_header FROM wa_header.
ENDIF.
ELSE.
wa_error = wa_header .
MOVE text-016 TO wa_error-text.
APPEND wa_error TO t_error.
DELETE TABLE t_header FROM wa_header.
ENDIF.
ENDIF.
********Rate Validation.
IF wa_header-kbetr = ' '.
wa_error = wa_header .
MOVE text-017 TO wa_error-text.
APPEND wa_error TO t_error.
DELETE TABLE t_header FROM wa_header.
ENDIF.
READ TABLE t_tvkov INTO wa_tvkov WITH KEY vkorg = wa_header-vkorg
BINARY SEARCH.
IF sy-subrc = 0.
READ TABLE t_tvkov INTO wa_tvkov WITH KEY vtweg = wa_header-vtweg
BINARY SEARCH.
IF sy-subrc <> 0.
wa_error = wa_header.
MOVE text-015 TO wa_error-text.
WRITE wa_header-vtweg TO wa_error-text+13(4).
APPEND wa_error TO t_error.
ENDIF.
ELSE.
wa_error = wa_header.
MOVE text-013 TO wa_error-text.
WRITE wa_header-vkorg TO wa_error-text+9(4).
APPEND wa_error TO t_error.
ENDIF.
CLEAR wa_header.
ENDLOOP.
*****Deleting Duplicate Material Form Header "Flat File Data".
SORT t_header BY kschl vkorg vtweg matnr.
DELETE ADJACENT DUPLICATES FROM t_header COMPARING
kschl! vkorg vtweg matnr .
****Data Moving from Header to Item Level.
t_item[] = t_header[].
*To count No.of records in Item Table.
DESCRIBE TABLE t_item LINES v_count.
CONCATENATE text-014 ' ' v_count INTO v_bdc.
****Popup to get Confirmation from user to process BDC
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = 'Confirmation of File Data'
text_question = v_bdc
text_button_1 = 'Confirm'
text_button_2 = 'Cancel Run'
default_button = '1'
IMPORTING
answer = c_ans.
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. " f_Process
*& Form f_Refresh
text
--> p1 text
<-- p2 text
FORM f_refresh.
REFRESH : t_xls_file,
t_header,
t_item,
t_mvke,
t_tvkov,
t_error,
t_mtab.
CLEAR : t_xls_file,
wa_header,
wa_item,
wa_mvke,
wa_tvkov,
wa_error,
wa_mtab.
ENDFORM. " f_Refresh
ALSO PLEASE CHECK OUT
sample code for call transaction method
http://www.sapdevelopment.co.uk/bdc/bdc_ctcode.htm
chk this for BDC recording with screen shots
http://www.sapdevelopment.co.uk/bdc/bdc_recording.htm
BDC
http://www.sap-img.com/bdc.htm
Table control in BDC
http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
best typical example is BDC for MM01
check the below links for the same
bdc for MM01.
mm01
bdc mm01
BDC
http://www.sap-img.com/bdc.htm
http://www.guidancetech.com/people/holland/sap/abap/zzsni001.htm
http://www.sappoint.com/abap/bdcconcept.pdf
Difference between Genrate session& Call transaction
Re: Steps in BDC -
I need some standard reports regarding Purchage Data Analysis Report and Open Sales order report .
Thanks & Regards
Satish PatnaikHi,
Check the following links:
http://sap-img.com/abap/make-e-mail-sender-of-po-the-po-creators-name.htm
http://sap-img.com/abap/sending-mail-when-the-purchase-order-is-released.htm
Regards,
Naresh -
Hi guru's i want to dovelope or modify bapi how we can give name for bapi
hi guru's i want to dovelope or modify bapi how we can give name for bapi plz help me...
Hi,
If u want to assign the form to Standard sales order, The, this form in the NACE.
and the, Run from va02/03.
Reward Points,
Vamsi. -
Error in bdc programing code-pls help
hi friends,
I was tring to do a bdc program.But it shows me an error. MY bdc program is jus to upload a 2 fields in vendoe master table.
That is LIFNR,NAME1 field for the new vendors.
I worked out an execl sheet for this, and jus copied it to the text file by selecting all and pasting.
Even then i get an error code that BDC_open does not exits.
MY code is this, please help me if iam wrong.
If anyone can help to make it more understandable,I Kindly request you to try out this program with the screen shot and mail to this id [email protected] would be very thankful for your timely help.
report Z_PK_BDC
no standard page heading line-size 255.
include bdcrecx1.
parameters: dataset(132) lower case.
parameters: p_file like rlgrap-filename default
'C:\SAP TESTING\p_file.txt'.
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: LIF16
LIFNR_001(016),
data element: BUKRS
BUKRS_002(004),
data element: KTOKK
KTOKK_003(004),
data element: ANRED
ANRED_004(015),
data element: NAME1_GP
NAME1_005(035),
data element: SORTL
SORTL_006(010),
data element: NAME2_GP
NAME2_007(035),
data element: STRAS_GP
STRAS_008(035),
data element: ORT01_GP
ORT01_009(035),
data element: ORT02_GP
ORT02_010(035),
data element: PFORT_GP
PFORT_011(035),
data element: LAND1_GP
LAND1_012(003),
data element: SPRAS
SPRAS_013(002),
end of record.
End generated data section ***
start-of-selection.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = P_FILE
FILETYPE = 'DAT'
TABLES
DATA_TAB = record
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 <> 0.
WRITE:/ 'SY-SUBRC:', SY-SUBRC.
ENDIF.
LOOP AT RECORD.
*perform open_dataset using dataset.
*perform open_group.
*do.
*read dataset dataset into record.
*if sy-subrc <> 0. exit. endif.
perform bdc_dynpro using 'SAPMF02K' '0105'.
perform bdc_field using 'BDC_CURSOR'
'RF02K-KTOKK'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02K-LIFNR'
record-LIFNR_001.
perform bdc_field using 'RF02K-BUKRS'
record-BUKRS_002.
perform bdc_field using 'RF02K-KTOKK'
record-KTOKK_003.
perform bdc_dynpro using 'SAPMF02K' '0110'.
perform bdc_field using 'BDC_CURSOR'
'LFA1-SPRAS'.
perform bdc_field using 'BDC_OKCODE'
'=UPDA'.
perform bdc_field using 'LFA1-ANRED'
record-ANRED_004.
perform bdc_field using 'LFA1-NAME1'
record-NAME1_005.
perform bdc_field using 'LFA1-SORTL'
record-SORTL_006.
perform bdc_field using 'LFA1-NAME2'
record-NAME2_007.
perform bdc_field using 'LFA1-STRAS'
record-STRAS_008.
perform bdc_field using 'LFA1-ORT01'
record-ORT01_009.
perform bdc_field using 'LFA1-ORT02'
record-ORT02_010.
perform bdc_field using 'LFA1-PFORT'
record-PFORT_011.
perform bdc_field using 'LFA1-LAND1'
record-LAND1_012.
perform bdc_field using 'LFA1-SPRAS'
record-SPRAS_013.
perform bdc_transaction using 'FK01'.
**enddo.
**perform close_group.
endloop.
**perform close_dataset using dataset.
Thanks in Advance
Rinky123Hi,
If you are using GUI_UPLOAD in 4.7 then the file path whatever you are using currently it won't work. Replace the file path like this.
P_FILE LIKE RLGRAP-FILENAME.
DATA: V_FILE TYPE STRING.
V_FILE = P_FILE.
Now take this v_file for function module.Then only it will open the file otherwise you won't get unable to open file error message.
I observerd that you are getting so many fields from the file to the internal table.
Maybe you are looking for
-
How to create a forum on adobe muse
I have a idea for a forum and I am wondering if I can make one adobe. If so please tell me, if not can you inform me of any other way I can.
-
HT1848 I press my iTunes app button and it flickers on then goes off? Can you help pls
I Press my iTunes app and it comes on, flickers then goes off? Can you help pls
-
How to use bulk insert in utl_file
i am creating text file of employee list i go huge data i want to use bulk insert with utl_file is it possible if so, how pls help me.
-
My ipad 2 pictures are all grainy, my wifes i pad 2 pis are great
when i hold the 2 ipads side by side and take a picture , mine is all grainy, hers is great , what is going on . as i look through the history of my photos , they seem to have gone downhill after i upgraded to i0s 6.whatever
-
Oracle 9i - Java Runtime Environment not found
I am trying to install Oracle 9i (9.2.0.1) for S/390 Linux on a SLES 9 SP 3 system. When I try to execute runInstaller, I receive the following error message: The Java Runtime Environment was not found at IBMJava2-s390-131/jre/bin/java. (text omitted