Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BDC

Former Member
0 Likes
707

Hi All,

Can anyone give an example program on BDC making use of Application server or file?

Regards,

Asia

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
670

Hi Asia,

Check this program.

REPORT YOPENDATASET .

TABLES : LFA1.

PARAMETERS : FILE(200) TYPE C.

DATA: BEGIN OF ITAB OCCURS 0,

LIFNR LIKE LFA1-LIFNR,

ORT01 LIKE LFA1-ORT01,

LAND1 LIKE LFA1-LAND1,

END OF ITAB.

DATA : BEGIN OF JTAB OCCURS 0.

INCLUDE STRUCTURE BDCDATA.

DATA : END OF JTAB.

OPEN DATASET FILE FOR INPUT IN BINARY MODE.

DO.

READ DATASET FILE INTO ITAB.

IF SY-SUBRC <> 0.

EXIT.

ENDIF.

PERFORM SUB USING 'YMPOOL' '100'.

PERFORM SUB1 USING : 'LFA1-LIFNR' ITAB-LIFNR,

'LFA1-ORT01' ITAB-ORT01,

'LFA1-LAND1' ITAB-LAND1.

CALL TRANSACTION 'YMTRAN' USING ITAB MODE 'A'.

ENDDO.

CLOSE DATASET FILE.

FORM SUB USING A B .

CLEAR JTAB.

JTAB-PROGRAM = A.

JTAB-DYNPRO = B.

JTAB-DYNBEGIN = 'X'.

APPEND JTAB.

ENDFORM.

FORM SUB1 USING C D.

CLEAR JTAB.

JTAB-FNAM = C.

JTAB-FVAL = D.

APPEND JTAB.

ENDFORM.

Hope this resolves your query.

Reward all the helpful answers.

Regards

6 REPLIES 6
Read only

Former Member
0 Likes
670

hi check this

report ZBDC_SEMIFIN

no standard page heading line-size 255.

include bdcrecx1.

Tables: Mara,"General Material Data

mard,"Storage Location Data for Material

mvke,"Sales Data for Material

Makt,"Material Descriptions

marc,"Plant Data for Material

mbew,"Material Valuation

rlgrap."Program Fields/Screen Fields for SAPLGRAP

Data: begin of ITAB occurs 0,"Internal table for Semi-Finished Material

  • Initial data

matnr like mara-matnr, "Material Code

mbrsh like mara-mbrsh, "Industry Data

mtart like mara-mtart, "Material Type

  • Org Data

Werks like marc-werks, "Plant

lgort like mard-lgort, "Storage Location

vkorg like mvke-vkorg, "Sales Orgnization

vtweg like mvke-vtweg, "Distribution Chanel

  • Basic 1

Maktx Like makt-maktx, "Description

meins like mara-meins, "Uom

matkl like mara-matkl, "Material Group

BISMT LIKE MARA-BISMT, " Old Material Number

spart like mara-spart, "Division

brgew(7),"like mara-brgew, "Gross Weight

gewei like MARA-GEWEI, "Weight Unit

ntgew(7)," like mara-ntgew, "Net Weight

  • Purchasing

MAKTL LIKE MARA-MATKL, "Material Group

ekwsl like MARA-EKWSL, " Purchasing Value Key

ekgrp like MARC-EKGRP, " Purchasing Group

  • Mrp 1

disgr like MARC-DISGR, "Mrp Group

  • ekgrp like MARC-EKGRP, "Purchasing group

dismm like MARC-DISMM, "Mrp Type

dispo like MARC-DISPO, "Mrp Controller

disls like MARC-DISLS, "Lot Size

BSTMI like MARC-BSTMI,

BSTMA like MARC-BSTMA,

BSTRF like MARC-BSTRF,

BSTFE like MARC-BSTFE,

  • Mrp 2

beskz like MARC-BESKZ, "Procurement type

lgpro like MARC-LGPRO, "Production Storage Location

dzeit(3),"like MARC-DZEIT, "In house Production time

plifz(3),"like MARC-PLIFZ, "Planned delivery time

fhori(3),"like MARC-FHORI, "Sched margin key

eisbe like MARC-EISBE, "Safety stock

  • Mrp 3

PERKZ LIKE MARC-PERKZ,

vrmod like MARC-VRMOD, "Consumption mode

vint1(3)," like MARC-VINT1, "Backward Consumption period

vint2(3),"like MARC-VINT2, "Forward Consumption period

mtvfp like MARC-MTVFP, "Availability Check

  • Mrp 4

sbdkz like MARC-SBDKZ, "Individual/ Collective

SAUFT like MARC-SAUFT, "Repetitive Manufacturing

SFEPR like MARC-SFEPR, "REM Profile

  • Work Scheduling View

ausme like MARC-AUSME, "Unit of issue

FEVOR LIKE MARC-FEVOR, "Production Scheduler

SFCPF like MARC-SFCPF, "Production Scheduler Profile

umren(5)," like RMMZU-UMREN, "Val for base uom

umrez(5) ,"like RMMZU-UMREz, "Value for uo issue

  • Accounting 1

bklas like MBEW-BKLAS, "Valuation Class

vprsv like MBEW-VPRSV, "Price Control Indicator

verpr(7)," like MBEW-VERPR, "Value/Price

STPRS like MBEW-STPRS,

*COSTING

EKALR LIKE MBEW-EKALR," With qty str

LOSGR like MARC-LOSGR, " Costing Lot size

end of ITAB.

**********************************************************

Data: W_record type I, "Record Allready exists.

w_trecord type I. "Total record processed

start-of-selection.

perform upload. "Upload Data from Text File

Perform Open_group. "Create a session

clear : w_record,w_trecord.

perform semi. "Create Semi Finish Materials

if w_trecord gt 0 or w_record gt 0.

perform batch_job.

endif.

perform close_group. "Close session

FORM SEMI.

loop at ITAB.

  • Check for material in master *************************

select single * from mara where matnr eq ITAB-matnr.

if sy-subrc ne 0.

w_trecord = w_trecord + 1.

*Initial Screen

perform bdc_dynpro using 'SAPLMGMM' '0060'.

perform bdc_field using 'BDC_CURSOR'

'RMMG1-MTART'.

perform bdc_field using 'BDC_OKCODE'

'=AUSW'.

perform bdc_field using 'RMMG1-MATNR'

ITAB-MATNR.

perform bdc_field using 'RMMG1-MBRSH'

'M'.

perform bdc_field using 'RMMG1-MTART'

'HALB'.

**********************Views*********************************

*Select Views

perform bdc_dynpro using 'SAPLMGMM' '0070'.

perform bdc_field using 'BDC_CURSOR'

'MSICHTAUSW-DYTXT(17'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'MSICHTAUSW-KZSEL(01)'

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(09)'

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(12)'

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(13)'

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(14)'

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(15)'

'X'..

perform bdc_field using 'MSICHTAUSW-KZSEL(17)'

'X'.

**********************Views*********************************

*perform bdc_dynpro using 'SAPLMGMM' '0070'.

*perform bdc_field using 'BDC_CURSOR'

  • 'MSICHTAUSW-DYTXT(01)'.

*perform bdc_field using 'BDC_OKCODE'

  • '/00'.

*perform bdc_dynpro using 'SAPLMGMM' '0070'.

*perform bdc_field using 'BDC_CURSOR'

  • 'MSICHTAUSW-DYTXT(17)'.

*perform bdc_field using 'BDC_OKCODE'

  • '/00'.

*perform bdc_field using 'MSICHTAUSW-KZSEL(17)'

  • ITAB-KZSEL_17_011.

*perform bdc_dynpro using 'SAPLMGMM' '0070'.

*perform bdc_field using 'BDC_CURSOR'

  • 'MSICHTAUSW-DYTXT(01)'.

*perform bdc_field using 'BDC_OKCODE'

  • '/00'.

*perform bdc_dynpro using 'SAPLMGMM' '0070'.

*perform bdc_field using 'BDC_CURSOR'

  • 'MSICHTAUSW-DYTXT(13)'.

*perform bdc_field using 'BDC_OKCODE'

  • '=ENTR'.

*perform bdc_field using 'MSICHTAUSW-KZSEL(13)'

  • ITAB-KZSEL_13_012.

*Org Data

perform bdc_dynpro using 'SAPLMGMM' '0080'.

perform bdc_field using 'BDC_CURSOR'

'RMMG1-LGORT'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'RMMG1-WERKS'

ITAB-WERKS.

perform bdc_field using 'RMMG1-LGORT'

ITAB-LGORT.

*Basic 1

perform bdc_dynpro using 'SAPLMGMM' '4004'.

perform bdc_field using 'BDC_OKCODE'

'=SP09'.

perform bdc_field using 'MAKT-MAKTX'

ITAB-MAKTX.

perform bdc_field using 'MARA-MEINS'

ITAB-MEINS.

perform bdc_field using 'MARA-MATKL'

ITAB-MATKL.

perform bdc_field using 'MARA-BISMT'

ITAB-BISMT.

perform bdc_field using 'MARA-SPART'

ITAB-SPART.

perform bdc_field using 'MARA-MTPOS_MARA'

'NORM'.

perform bdc_field using 'BDC_CURSOR'

'MARA-NTGEW'.

perform bdc_field using 'MARA-BRGEW'

ITAB-BRGEW.

perform bdc_field using 'MARA-GEWEI'

ITAB-GEWEI.

perform bdc_field using 'MARA-NTGEW'

ITAB-NTGEW.

*Purchasing

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'=SP12'.

perform bdc_field using 'MAKT-MAKTX'

ITAB-MAKTX.

perform bdc_field using 'MARA-MEINS'

ITAB-MEINS.

perform bdc_field using 'MARC-EKGRP'

ITAB-EKGRP.

perform bdc_field using 'MARA-MATKL'

ITAB-MATKL.

perform bdc_field using 'BDC_CURSOR'

'MARA-EKWSL'.

perform bdc_field using 'MARA-EKWSL'

ITAB-EKWSL.

*MRP 1

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'=SP13'.

perform bdc_field using 'MAKT-MAKTX'

ITAB-MAKTX.

perform bdc_field using 'MARA-MEINS'

ITAB-MEINS.

perform bdc_field using 'MARC-EKGRP'

ITAB-EKGRP.

perform bdc_field using 'MARC-DISMM'

ITAB-DISMM.

perform bdc_field using 'MARC-DISPO'

ITAB-DISPO.

perform bdc_field using 'BDC_CURSOR'

'MARC-DISLS'.

perform bdc_field using 'MARC-DISLS'

ITAB-DISLS.

IF ITAB-DISLS EQ 'EX' .

perform bdc_field using 'MARC-BSTMI'

ITAB-BSTMI."MIN LOT SIZE

perform bdc_field using 'MARC-BSTMA'

ITAB-BSTMA."MAX LOT SIZE

perform bdc_field using 'MARC-BSTRF'

ITAB-BSTRF."RNDING

ELSEIF ITAB-DISLS EQ 'FX'.

perform bdc_field using 'MARC-BSTFE'

ITAB-BSTFE.

ENDIF.

*MRP 2

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'=SP14'.

perform bdc_field using 'MAKT-MAKTX'

ITAB-MAKTX.

perform bdc_field using 'MARC-BESKZ'

ITAB-BESKZ.

perform bdc_field using 'MARC-LGPRO'

ITAB-LGPRO.

perform bdc_field using 'MARC-DZEIT'

ITAB-DZEIT.

perform bdc_field using 'MARC-PLIFZ'

ITAB-PLIFZ.

perform bdc_field using 'MARC-FHORI'

ITAB-FHORI.

perform bdc_field using 'BDC_CURSOR'

'MARC-EISBE'.

perform bdc_field using 'MARC-EISBE'

ITAB-EISBE.

ITAB-PERKZ.

ITAB-MTVFP.

*MRP 4

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'=SP17'.

perform bdc_field using 'MARC-SFEPR'

ITAB-SFEPR.

*Work Scheduling

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

ITAB-SFCPF.

perform bdc_field using 'MARC-DZEIT'

ITAB-DZEIT.

*Check for Conversation Factor

if ITAB-MEINS ne iTAB-ausme and iTAB-umren gt 0

endif.

perform bdc_field using 'MARC-LGPRO'

itab-LGPRO.

perform bdc_field using 'MARC-DZEIT'

itab-DZEIT.

*Accounting

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'=SP26'.

perform bdc_field using 'MAKT-MAKTX'

perform bdc_field using 'MBEW-STPRS'

ITAB-STPRS.

IF ITAB-VPRSV = 'S'.

perform bdc_field using 'MBEW-STPRS' "FILLS STD PRICE

ITAB-VERPR.

ELSEIF ITAB-VPRSV ='V'.

perform bdc_field using 'MBEW-VERPR' "FILLS VALUE

ITAB-VERPR.

ENDIF.

*Cost Estimate

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'=BU'.

perform bdc_field using 'MAKT-MAKTX'

ITAB-MAKTX.

perform bdc_field using 'BDC_CURSOR'

'MARC-PRCTR'.

perform bdc_field using 'MARA-MEINS'

ITAB-MEINS.

perform bdc_field using 'MBEW-EKALR'

ITAB-EKALR.

perform bdc_field using 'MARC-LOSGR'

ITAB-LOSGR.

perform bdc_transaction using 'MM01'.

REFRESH BDCDATA.

  • *************************************************************

else.

w_record = w_record + 1.

endif.

ENDLOOP.

ENDFORM.

form Upload.

CALL FUNCTION 'UPLOAD'

EXPORTING

CODEPAGE = ' '

FILENAME = ' '

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.

ENDFORM.

form batch_job.

uline.

format color col_heading.

if w_trecord gt 0.

Write:/ 'Background Job has been Created for ',

w_trecord right-justified, 'Semi-Fin', 80 ''.

write:/ 'Please follow the following steps to run this job',

80 ''.

write:/ 'as listed below.', 80 ''.

format color col_normal.

skip.

write:/05 '1.Goto Transaction SM35', 80 ''.

write:/05 '2.Select your Session Name', 80 ''.

write:/05 '3.Click On Execute Button', 80 ''.

endif.

if w_record gt 0.

format color col_negative.

write:/ w_record ,'records already existed', 80 ''.

format color off.

endif.

uline.

endform.

Read only

Former Member
0 Likes
670

Hi,

See the Sample code for BDC using OPEN DATASET.

report ZSDBDCP_PRICING no standard page heading

line-size 255.

include zbdcrecx1.

*--Internal Table To hold condition records data from flat file.

Data: begin of it_pricing occurs 0,

key(4),

f1(4),

f2(4),

f3(2),

f4(18),

f5(16),

end of it_pricing.

*--Internal Table To hold condition records header .

data : begin of it_header occurs 0,

key(4),

f1(4),

f2(4),

f3(2),

end of it_header.

*--Internal Table To hold condition records details .

data : begin of it_details occurs 0,

key(4),

f4(18),

f5(16),

end of it_details.

data : v_sno(2),

v_rows type i,

v_fname(40).

start-of-selection.

refresh : it_pricing,it_header,it_details.

clear : it_pricing,it_header,it_details.

  • CALL FUNCTION 'UPLOAD'

  • EXPORTING

  • FILENAME = 'C:\WINDOWS\Desktop\pricing.txt'

  • FILETYPE = 'DAT'

  • TABLES

  • DATA_TAB = it_pricing

  • EXCEPTIONS

  • CONVERSION_ERROR = 1

  • INVALID_TABLE_WIDTH = 2

  • INVALID_TYPE = 3

  • NO_BATCH = 4

  • UNKNOWN_ERROR = 5

  • GUI_REFUSE_FILETRANSFER = 6

  • OTHERS = 7.

WRITE : / 'Condition Records ', P_FNAME, ' on ', SY-DATUM.

OPEN DATASET P_FNAME FOR INPUT IN TEXT MODE.

if sy-subrc ne 0.

write : / 'File could not be uploaded.. Check file name.'.

stop.

endif.

CLEAR : it_pricing[], it_pricing.

DO.

READ DATASET P_FNAME INTO V_STR.

IF SY-SUBRC NE 0.

EXIT.

ENDIF.

  • write v_str.

  • translate v_str using '#/'.

SPLIT V_STR AT ',' INTO it_pricing-key

it_pricing-F1 it_pricing-F2 it_pricing-F3

it_pricing-F4 it_pricing-F5 .

APPEND it_pricing.

CLEAR it_pricing.

ENDDO.

IF it_pricing[] IS INITIAL.

WRITE : / 'No data found to upload'.

STOP.

ENDIF.

loop at it_pricing.

At new key.

read table it_pricing index sy-tabix.

move-corresponding it_pricing to it_header.

append it_header.

clear it_header.

endat.

move-corresponding it_pricing to it_details.

append it_details.

clear it_details.

endloop.

perform open_group.

v_rows = sy-srows - 8.

loop at it_header.

perform bdc_dynpro using 'SAPMV13A' '0100'.

perform bdc_field using 'BDC_CURSOR'

'RV13A-KSCHL'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RV13A-KSCHL'

it_header-f1.

perform bdc_dynpro using 'SAPMV13A' '1004'.

perform bdc_field using 'BDC_CURSOR'

'KONP-KBETR(01)'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'KOMG-VKORG'

it_header-f2.

perform bdc_field using 'KOMG-VTWEG'

it_header-f3.

**Table Control

v_sno = 0.

loop at it_details where key eq it_header-key.

v_sno = v_sno + 1.

clear v_fname.

CONCATENATE 'KOMG-MATNR(' V_SNO ')' INTO V_FNAME.

perform bdc_field using v_fname

it_details-f4.

clear v_fname.

CONCATENATE 'KONP-KBETR(' V_SNO ')' INTO V_FNAME.

perform bdc_field using v_fname

it_details-f5.

if v_sno eq v_rows.

v_sno = 0.

perform bdc_dynpro using 'SAPMV13A' '1004'.

perform bdc_field using 'BDC_OKCODE'

'=P+'.

perform bdc_dynpro using 'SAPMV13A' '1004'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

endif.

endloop.

*--Save

perform bdc_dynpro using 'SAPMV13A' '1004'.

perform bdc_field using 'BDC_OKCODE'

'=SICH'.

perform bdc_transaction using 'VK11'.

endloop.

perform close_group.

reward if useful

regards,

Anji

Read only

Former Member
0 Likes
672

Hi Asia,

Check this program.

REPORT YOPENDATASET .

TABLES : LFA1.

PARAMETERS : FILE(200) TYPE C.

DATA: BEGIN OF ITAB OCCURS 0,

LIFNR LIKE LFA1-LIFNR,

ORT01 LIKE LFA1-ORT01,

LAND1 LIKE LFA1-LAND1,

END OF ITAB.

DATA : BEGIN OF JTAB OCCURS 0.

INCLUDE STRUCTURE BDCDATA.

DATA : END OF JTAB.

OPEN DATASET FILE FOR INPUT IN BINARY MODE.

DO.

READ DATASET FILE INTO ITAB.

IF SY-SUBRC <> 0.

EXIT.

ENDIF.

PERFORM SUB USING 'YMPOOL' '100'.

PERFORM SUB1 USING : 'LFA1-LIFNR' ITAB-LIFNR,

'LFA1-ORT01' ITAB-ORT01,

'LFA1-LAND1' ITAB-LAND1.

CALL TRANSACTION 'YMTRAN' USING ITAB MODE 'A'.

ENDDO.

CLOSE DATASET FILE.

FORM SUB USING A B .

CLEAR JTAB.

JTAB-PROGRAM = A.

JTAB-DYNPRO = B.

JTAB-DYNBEGIN = 'X'.

APPEND JTAB.

ENDFORM.

FORM SUB1 USING C D.

CLEAR JTAB.

JTAB-FNAM = C.

JTAB-FVAL = D.

APPEND JTAB.

ENDFORM.

Hope this resolves your query.

Reward all the helpful answers.

Regards

Read only

0 Likes
670

Hi Nagaraj,

Thanks a lot.

Regards,

Asia

Read only

Former Member
0 Likes
670

Hi,

check this program.

report ZBH_PURORDER no standard page heading line-size 255.

PARAMETERS:P_FILE LIKE IBIPPARMS-PATH.

DATA FILENAME TYPE STRING.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

program_name = sy-cprog

dynpro_number = sy-dynnr

IMPORTING

file_name = P_FILE.

START-OF-SELECTION.

FILENAME = P_FILE.

DATA:BEGIN OF XTAB OCCURS 0,

TYP,

DES(255) TYPE C,

END OF XTAB.

DATA:BEGIN OF ITAB OCCURS 0,

SUPERFIELD LIKE MEPO_TOPLINE-SUPERFIELD,

EKORG LIKE MEPO1222-EKORG,

EKGRP LIKE MEPO1222-EKGRP,

BUKRS LIKE MEPO1222-BUKRS,

END OF ITAB.

DATA:BEGIN OF JTAB OCCURS 0,

N(4) TYPE C,

EMATN LIKE MEPO1211-EMATN,

MENGE(13) TYPE C,

NETPR(13) TYPE C,

NAME1 LIKE MEPO1211-NAME1,

END OF JTAB.

DATA:BDCTAB LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

DATA:DELIMITER VALUE '*'.

DATA A TYPE I.

DATA M(4) TYPE N.

DATA L_FNAM(30) TYPE C.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = FILENAME

FILETYPE = 'ASC'

TABLES

DATA_TAB = XTAB.

LOOP AT XTAB.

IF XTAB-TYP = 'H'.

SPLIT XTAB-DES AT DELIMITER INTO ITAB-SUPERFIELD ITAB-EKORG ITAB-EKGRP

ITAB-BUKRS.

JTAB-N = JTAB-N + 1.

APPEND ITAB.

ELSEIF XTAB-TYP = 'I'.

SPLIT XTAB-DES AT DELIMITER INTO JTAB-EMATN JTAB-MENGE JTAB-NETPR

JTAB-NAME1.

APPEND JTAB.

ENDIF.

ENDLOOP.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

CLIENT = SY-MANDT

GROUP = 'PORDER'

KEEP = 'X'

USER = SY-UNAME.

LOOP AT ITAB.

A = SY-TABIX.

REFRESH BDCTAB.

perform bdc_dynpro using 'SAPLMEGUI' '0014'.

perform bdc_field using 'BDC_CURSOR'

'MEPO_TOPLINE-SUPERFIELD'.

perform bdc_field using 'MEPO_TOPLINE-BSART'

'NB'.

perform bdc_field using 'MEPO_TOPLINE-SUPERFIELD'

ITAB-SUPERFIELD.

perform bdc_field using 'MEPO_TOPLINE-BEDAT'

'09.02.2007'.

perform bdc_field using 'DYN_6000-LIST'

' 1'.

perform bdc_field using 'BDC_OKCODE'

'=MEV4000BUTTON'.

perform bdc_dynpro using 'SAPLMEGUI' '0014'.

perform bdc_field using 'MEPO_TOPLINE-BSART'

'NB'.

perform bdc_field using 'MEPO_TOPLINE-SUPERFIELD'

ITAB-SUPERFIELD.

perform bdc_field using 'MEPO_TOPLINE-BEDAT'

'09.02.2007'.

perform bdc_field using 'BDC_CURSOR'

'MEPO1222-EKORG'.

perform bdc_field using 'MEPO1222-EKORG'

ITAB-EKORG.

perform bdc_field using 'MEPO1222-EKGRP'

ITAB-EKGRP.

perform bdc_field using 'MEPO1222-BUKRS'

ITAB-BUKRS.

perform bdc_field using 'DYN_6000-LIST'

' 1'.

perform bdc_field using 'BDC_OKCODE'

'=MEV4001BUTTON'.

perform bdc_dynpro using 'SAPLMEGUI' '0014'.

perform bdc_field using 'MEPO_TOPLINE-BSART'

'NB'.

perform bdc_field using 'MEPO_TOPLINE-SUPERFIELD'

ITAB-SUPERFIELD.

perform bdc_field using 'MEPO_TOPLINE-BEDAT'

'09.02.2007'.

perform bdc_field using 'MEPO1222-EKORG'

ITAB-EKORG.

perform bdc_field using 'MEPO1222-EKGRP'

ITAB-EKGRP.

perform bdc_field using 'MEPO1222-BUKRS'

ITAB-BUKRS.

M = 1.

LOOP AT JTAB.

IF JTAB-N = A.

WRITE:/ JTAB.

CONCATENATE 'MEPO1211-EMATN(' M ')' INTO L_FNAM.

perform bdc_field using 'BDC_CURSOR'

L_FNAM.

perform bdc_field using L_FNAM

JTAB-EMATN.

CONCATENATE 'MEPO1211-MENGE(' M ')' INTO L_FNAM.

perform bdc_field using L_FNAM

JTAB-MENGE.

CONCATENATE 'MEPO1211-NETPR(' M ')' INTO L_FNAM.

perform bdc_field using L_FNAM

JTAB-NETPR.

CONCATENATE 'MEPO1211-NAME1(' M ')' INTO L_FNAM.

perform bdc_field using L_FNAM

JTAB-NAME1.

M = M + 1.

ENDIF.

ENDLOOP.

perform bdc_field using 'DYN_6000-LIST'

' 1'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_dynpro using 'SAPLMEGUI' '0014'.

perform bdc_field using 'MEPO_TOPLINE-BSART'

'NB'.

perform bdc_field using 'MEPO_TOPLINE-SUPERFIELD'

ITAB-SUPERFIELD.

perform bdc_field using 'MEPO_TOPLINE-BEDAT'

'09.02.2007'.

perform bdc_field using 'MEPO1222-EKORG'

ITAB-EKORG.

perform bdc_field using 'MEPO1222-EKGRP'

ITAB-EKGRP.

perform bdc_field using 'MEPO1222-BUKRS'

ITAB-BUKRS.

perform bdc_field using 'DYN_6000-LIST'

' 1'.

perform bdc_field using 'BDC_CURSOR'

'MEPO1319-MATKL'.

perform bdc_field using 'MEPO1319-SPINF'

'X'.

perform bdc_field using 'BDC_OKCODE'

'=MESAVE'.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

TCODE = 'ME21N'

TABLES

DYNPROTAB = BDCTAB.

ENDLOOP.

CALL FUNCTION 'BDC_CLOSE_GROUP'.

FORM BDC_DYNPRO USING PROGRAM DYNPRO.

CLEAR BDCTAB.

BDCTAB-PROGRAM = PROGRAM.

BDCTAB-DYNPRO = DYNPRO.

BDCTAB-DYNBEGIN = 'X'.

APPEND BDCTAB.

ENDFORM.

FORM BDC_FIELD USING FNAM FVAL.

CLEAR BDCTAB.

BDCTAB-FNAM = FNAM.

BDCTAB-FVAL = FVAL.

APPEND BDCTAB.

ENDFORM.

FLAT FILE:

H1171611000001*1000

ICPU116000*1000

ILEY BOARD1010000*1000

IMOUSE66000*1000

H1171711000001*1000

ICPU580000*1000

H1171701000001*1000

IMOUSE33000*1000

ILEY BOARD1010000*1000

rgds,

bharat.

Read only

Former Member
0 Likes
670

Hi Asia,

look into this code:

*****************************************************

***This is a BDC for Semi finished Materials*******

report ZBDC_SEMIFIN

no standard page heading line-size 255.

include bdcrecx1.

Tables: Mara,"General Material Data

mard,"Storage Location Data for Material

mvke,"Sales Data for Material

Makt,"Material Descriptions

marc,"Plant Data for Material

mbew,"Material Valuation

rlgrap."Program Fields/Screen Fields for SAPLGRAP

Data: begin of ITAB occurs 0,"Internal table for Semi-Finished Material

  • Initial data

matnr like mara-matnr, "Material Code

mbrsh like mara-mbrsh, "Industry Data

mtart like mara-mtart, "Material Type

  • Org Data

Werks like marc-werks, "Plant

lgort like mard-lgort, "Storage Location

vkorg like mvke-vkorg, "Sales Orgnization

vtweg like mvke-vtweg, "Distribution Chanel

  • Basic 1

Maktx Like makt-maktx, "Description

meins like mara-meins, "Uom

matkl like mara-matkl, "Material Group

BISMT LIKE MARA-BISMT, " Old Material Number

spart like mara-spart, "Division

brgew(7),"like mara-brgew, "Gross Weight

gewei like MARA-GEWEI, "Weight Unit

ntgew(7)," like mara-ntgew, "Net Weight

  • Purchasing

MAKTL LIKE MARA-MATKL, "Material Group

ekwsl like MARA-EKWSL, " Purchasing Value Key

ekgrp like MARC-EKGRP, " Purchasing Group

  • Mrp 1

disgr like MARC-DISGR, "Mrp Group

  • ekgrp like MARC-EKGRP, "Purchasing group

dismm like MARC-DISMM, "Mrp Type

dispo like MARC-DISPO, "Mrp Controller

disls like MARC-DISLS, "Lot Size

BSTMI like MARC-BSTMI,

BSTMA like MARC-BSTMA,

BSTRF like MARC-BSTRF,

BSTFE like MARC-BSTFE,

  • Mrp 2

beskz like MARC-BESKZ, "Procurement type

lgpro like MARC-LGPRO, "Production Storage Location

dzeit(3),"like MARC-DZEIT, "In house Production time

plifz(3),"like MARC-PLIFZ, "Planned delivery time

fhori(3),"like MARC-FHORI, "Sched margin key

eisbe like MARC-EISBE, "Safety stock

  • Mrp 3

PERKZ LIKE MARC-PERKZ,

vrmod like MARC-VRMOD, "Consumption mode

vint1(3)," like MARC-VINT1, "Backward Consumption period

vint2(3),"like MARC-VINT2, "Forward Consumption period

mtvfp like MARC-MTVFP, "Availability Check

  • Mrp 4

sbdkz like MARC-SBDKZ, "Individual/ Collective

SAUFT like MARC-SAUFT, "Repetitive Manufacturing

SFEPR like MARC-SFEPR, "REM Profile

  • Work Scheduling View

ausme like MARC-AUSME, "Unit of issue

FEVOR LIKE MARC-FEVOR, "Production Scheduler

SFCPF like MARC-SFCPF, "Production Scheduler Profile

umren(5)," like RMMZU-UMREN, "Val for base uom

umrez(5) ,"like RMMZU-UMREz, "Value for uo issue

  • Accounting 1

bklas like MBEW-BKLAS, "Valuation Class

vprsv like MBEW-VPRSV, "Price Control Indicator

verpr(7)," like MBEW-VERPR, "Value/Price

STPRS like MBEW-STPRS,

*COSTING

EKALR LIKE MBEW-EKALR," With qty str

LOSGR like MARC-LOSGR, " Costing Lot size

end of ITAB.

**********************************************************

Data: W_record type I, "Record Allready exists.

w_trecord type I. "Total record processed

start-of-selection.

perform upload. "Upload Data from Text File

Perform Open_group. "Create a session

clear : w_record,w_trecord.

perform semi. "Create Semi Finish Materials

if w_trecord gt 0 or w_record gt 0.

perform batch_job.

endif.

perform close_group. "Close session

FORM SEMI.

loop at ITAB.

  • Check for material in master *************************

select single * from mara where matnr eq ITAB-matnr.

if sy-subrc ne 0.

w_trecord = w_trecord + 1.

*Initial Screen

perform bdc_dynpro using 'SAPLMGMM' '0060'.

perform bdc_field using 'BDC_CURSOR'

'RMMG1-MTART'.

perform bdc_field using 'BDC_OKCODE'

'=AUSW'.

perform bdc_field using 'RMMG1-MATNR'

ITAB-MATNR.

perform bdc_field using 'RMMG1-MBRSH'

'M'.

perform bdc_field using 'RMMG1-MTART'

'HALB'.

**********************Views*********************************

*Select Views

perform bdc_dynpro using 'SAPLMGMM' '0070'.

perform bdc_field using 'BDC_CURSOR'

'MSICHTAUSW-DYTXT(17'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'MSICHTAUSW-KZSEL(01)'

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(09)'

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(12)'

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(13)'

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(14)'

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(15)'

'X'..

perform bdc_field using 'MSICHTAUSW-KZSEL(17)'

'X'.

**********************Views*********************************

*perform bdc_dynpro using 'SAPLMGMM' '0070'.

*perform bdc_field using 'BDC_CURSOR'

  • 'MSICHTAUSW-DYTXT(01)'.

*perform bdc_field using 'BDC_OKCODE'

  • '/00'.

*perform bdc_dynpro using 'SAPLMGMM' '0070'.

*perform bdc_field using 'BDC_CURSOR'

  • 'MSICHTAUSW-DYTXT(17)'.

*perform bdc_field using 'BDC_OKCODE'

  • '/00'.

*perform bdc_field using 'MSICHTAUSW-KZSEL(17)'

  • ITAB-KZSEL_17_011.

*perform bdc_dynpro using 'SAPLMGMM' '0070'.

*perform bdc_field using 'BDC_CURSOR'

  • 'MSICHTAUSW-DYTXT(01)'.

*perform bdc_field using 'BDC_OKCODE'

  • '/00'.

*perform bdc_dynpro using 'SAPLMGMM' '0070'.

*perform bdc_field using 'BDC_CURSOR'

  • 'MSICHTAUSW-DYTXT(13)'.

*perform bdc_field using 'BDC_OKCODE'

  • '=ENTR'.

*perform bdc_field using 'MSICHTAUSW-KZSEL(13)'

  • ITAB-KZSEL_13_012.

*Org Data

perform bdc_dynpro using 'SAPLMGMM' '0080'.

perform bdc_field using 'BDC_CURSOR'

'RMMG1-LGORT'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'RMMG1-WERKS'

ITAB-WERKS.

perform bdc_field using 'RMMG1-LGORT'

ITAB-LGORT.

*Basic 1

perform bdc_dynpro using 'SAPLMGMM' '4004'.

perform bdc_field using 'BDC_OKCODE'

'=SP09'.

perform bdc_field using 'MAKT-MAKTX'

ITAB-MAKTX.

perform bdc_field using 'MARA-MEINS'

ITAB-MEINS.

perform bdc_field using 'MARA-MATKL'

ITAB-MATKL.

perform bdc_field using 'MARA-BISMT'

ITAB-BISMT.

perform bdc_field using 'MARA-SPART'

ITAB-SPART.

perform bdc_field using 'MARA-MTPOS_MARA'

'NORM'.

perform bdc_field using 'BDC_CURSOR'

'MARA-NTGEW'.

perform bdc_field using 'MARA-BRGEW'

ITAB-BRGEW.

perform bdc_field using 'MARA-GEWEI'

ITAB-GEWEI.

perform bdc_field using 'MARA-NTGEW'

ITAB-NTGEW.

*Purchasing

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'=SP12'.

perform bdc_field using 'MAKT-MAKTX'

ITAB-MAKTX.

perform bdc_field using 'MARA-MEINS'

ITAB-MEINS.

perform bdc_field using 'MARC-EKGRP'

ITAB-EKGRP.

perform bdc_field using 'MARA-MATKL'

ITAB-MATKL.

perform bdc_field using 'BDC_CURSOR'

'MARA-EKWSL'.

perform bdc_field using 'MARA-EKWSL'

ITAB-EKWSL.

*MRP 1

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'=SP13'.

perform bdc_field using 'MAKT-MAKTX'

ITAB-MAKTX.

perform bdc_field using 'MARA-MEINS'

ITAB-MEINS.

perform bdc_field using 'MARC-EKGRP'

ITAB-EKGRP.

perform bdc_field using 'MARC-DISMM'

ITAB-DISMM.

perform bdc_field using 'MARC-DISPO'

ITAB-DISPO.

perform bdc_field using 'BDC_CURSOR'

'MARC-DISLS'.

perform bdc_field using 'MARC-DISLS'

ITAB-DISLS.

IF ITAB-DISLS EQ 'EX' .

perform bdc_field using 'MARC-BSTMI'

ITAB-BSTMI."MIN LOT SIZE

perform bdc_field using 'MARC-BSTMA'

ITAB-BSTMA."MAX LOT SIZE

perform bdc_field using 'MARC-BSTRF'

ITAB-BSTRF."RNDING

ELSEIF ITAB-DISLS EQ 'FX'.

perform bdc_field using 'MARC-BSTFE'

ITAB-BSTFE.

ENDIF.

*MRP 2

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'=SP14'.

perform bdc_field using 'MAKT-MAKTX'

ITAB-MAKTX.

perform bdc_field using 'MARC-BESKZ'

ITAB-BESKZ.

perform bdc_field using 'MARC-LGPRO'

ITAB-LGPRO.

perform bdc_field using 'MARC-DZEIT'

ITAB-DZEIT.

perform bdc_field using 'MARC-PLIFZ'

ITAB-PLIFZ.

perform bdc_field using 'MARC-FHORI'

ITAB-FHORI.

perform bdc_field using 'BDC_CURSOR'

'MARC-EISBE'.

perform bdc_field using 'MARC-EISBE'

ITAB-EISBE.

*MRP 3

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'=SP15'.

perform bdc_field using 'MAKT-MAKTX'

ITAB-MAKTX.

perform bdc_field using 'MARC-PERKZ'

ITAB-PERKZ.

perform bdc_field using 'MARC-VRMOD'

ITAB-VRMOD.

perform bdc_field using 'MARC-VINT1'

ITAB-VINT1.

perform bdc_field using 'MARC-VINT2'

ITAB-VINT2.

perform bdc_field using 'BDC_CURSOR'

'MARC-MTVFP'.

perform bdc_field using 'MARC-MTVFP'

ITAB-MTVFP.

*MRP 4

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'=SP17'.

perform bdc_field using 'MAKT-MAKTX'

ITAB-MAKTX.

perform bdc_field using 'MARC-SBDKZ'

ITAB-SBDKZ.

perform bdc_field using 'BDC_CURSOR'

'MARC-SFEPR'.

perform bdc_field using 'MARC-SAUFT'

ITAB-SAUFT.

perform bdc_field using 'MARC-SFEPR'

ITAB-SFEPR.

*Work Scheduling

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'=SP24'.

perform bdc_field using 'MAKT-MAKTX'

ITAB-MAKTX.

perform bdc_field using 'BDC_CURSOR'

'MARC-SFCPF'.

perform bdc_field using 'MARA-MEINS'

ITAB-MEINS.

perform bdc_field using 'MARC-FEVOR'

ITAB-FEVOR.

perform bdc_field using 'MARC-LGPRO'

ITAB-LGPRO.

perform bdc_field using 'MARC-SFCPF'

ITAB-SFCPF.

perform bdc_field using 'MARC-DZEIT'

ITAB-DZEIT.

*Check for Conversation Factor

if ITAB-MEINS ne iTAB-ausme and iTAB-umren gt 0

and iTAB-umrez gt 0.

perform bdc_dynpro using 'SAPLMGMM' '0510'.

perform bdc_field using:

'BDC_OKCODE' '=ENTR',

'RMMZU-UMREN' ITAB-UMREN,

'RMMZU-UMREZ' ITAB-UMREZ.

endif.

perform bdc_field using 'MARC-LGPRO'

itab-LGPRO.

perform bdc_field using 'MARC-DZEIT'

itab-DZEIT.

*Accounting

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'=SP26'.

perform bdc_field using 'MAKT-MAKTX'

ITAB-MAKTX.

perform bdc_field using 'MARA-MEINS'

ITAB-MEINS.

perform bdc_field using 'MARA-SPART'

ITAB-SPART.

perform bdc_field using 'BDC_CURSOR'

'MBEW-STPRS'.

perform bdc_field using 'MBEW-BKLAS'

ITAB-BKLAS.

perform bdc_field using 'MBEW-VPRSV'

ITAB-VPRSV.

perform bdc_field using 'MBEW-STPRS'

ITAB-STPRS.

IF ITAB-VPRSV = 'S'.

perform bdc_field using 'MBEW-STPRS' "FILLS STD PRICE

ITAB-VERPR.

ELSEIF ITAB-VPRSV ='V'.

perform bdc_field using 'MBEW-VERPR' "FILLS VALUE

ITAB-VERPR.

ENDIF.

*Cost Estimate

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'=BU'.

perform bdc_field using 'MAKT-MAKTX'

ITAB-MAKTX.

perform bdc_field using 'BDC_CURSOR'

'MARC-PRCTR'.

perform bdc_field using 'MARA-MEINS'

ITAB-MEINS.

perform bdc_field using 'MBEW-EKALR'

ITAB-EKALR.

perform bdc_field using 'MARC-LOSGR'

ITAB-LOSGR.

perform bdc_transaction using 'MM01'.

REFRESH BDCDATA.

  • *************************************************************

else.

w_record = w_record + 1.

endif.

ENDLOOP.

ENDFORM.

form Upload.

CALL FUNCTION 'UPLOAD'

EXPORTING

CODEPAGE = ' '

FILENAME = ' '

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.

ENDFORM.

form batch_job.

uline.

format color col_heading.

if w_trecord gt 0.

Write:/ 'Background Job has been Created for ',

w_trecord right-justified, 'Semi-Fin', 80 ''.

write:/ 'Please follow the following steps to run this job',

80 ''.

write:/ 'as listed below.', 80 ''.

format color col_normal.

skip.

write:/05 '1.Goto Transaction SM35', 80 ''.

write:/05 '2.Select your Session Name', 80 ''.

write:/05 '3.Click On Execute Button', 80 ''.

endif.

if w_record gt 0.

format color col_negative.

write:/ w_record ,'records already existed', 80 ''.

format color off.

endif.

uline.

endform.

If this is ok then dont forget to award points.

Thanks and regards

Vipin Das