Application Development 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: 

Bdc

Former Member
0 Kudos
80

Hi,

Please give a exp. BDC( Application server).

1 ACCEPTED SOLUTION

Former Member
0 Kudos
45

Hi,

i thing this will help u.

REPORT Zxyzzzzzzz.

*REPORT ZDEL_FILE_CREATE_IN_APPLI_SER line-size 400.

*

  • NEW TABLES 20/10/2001 ADDITION START

TABLES : T001W,

MARA,

MCHA,

KNA1.

*

DATA : BEGIN OF ITAB OCCURS 1,

VKORG LIKE VBAK-VKORG , "SALES ORGANIZATION

VTWEG LIKE VBAK-VTWEG, "DISTRIBUTION CHANNEL

DIV(9), "Division Code

VSTEL LIKE LIKP-VSTEL, "SHIPPING POINT EG: CF01

DATBI(19), "SELECTION DATE

VGBEL LIKE LIPS-VGBEL, "SALES ORDER "d

KUNNR(10), "SAP CUSTOMER

MATNR LIKE LIPS-MATNR, "MATL NO "d

CHARG LIKE LIPS-CHARG, "BATCH NO "d

LFIMG(13), "DELIVERY QTY "d

free_qty(13), "not used in SAP "d

LTEXT1(9), "PACKING NO

LTEXT2(9), "ALLOCATION NO

LTEXT3(9), "C&F SALES INVOICE NO "d

VGBEL1 LIKE LIPS-VGBEL, "SALES ORDER "d

VSTEL1 LIKE LIKP-VSTEL, "SHIPPING POINT EG: CF01

DATBI1(19), "SELECTION DATE

END OF ITAB.

data : begin of header_itab occurs 0,

ltext3(9),

end of header_itab.

*******add on 22.10.01

  • NEW INTERNAL TABLES 20/10/2001 ADDITION START

DATA : BEGIN OF PLANTTAB OCCURS 1,

VSTEL1 LIKE LIKP-VSTEL, "SHIPPING POINT EG: CF01

VGBEL1 LIKE LIPS-VGBEL, "SALES ORDER

LTEXT3(9), "C&F SALES INVOICE NO

END OF PLANTTAB.

*

DATA : BEGIN OF MATTAB OCCURS 1,

MATNR LIKE LIPS-MATNR, "MATL NO

VGBEL1 LIKE LIPS-VGBEL, "SALES ORDER

LTEXT3(9), "C&F SALES INVOICE NO

END OF MATTAB.

*

DATA : BEGIN OF BATCHTAB OCCURS 1,

MATNR LIKE LIPS-MATNR, "MATL NO

VSTEL1 LIKE LIKP-VSTEL, "SHIPPING POINT EG: CF01

CHARG LIKE LIPS-CHARG, "BATCH NO

VGBEL1 LIKE LIPS-VGBEL, "SALES ORDER

LTEXT3(9), "C&F SALES INVOICE NO

END OF BATCHTAB.

*

DATA : BEGIN OF CUSTTAB OCCURS 1,

KUNNR(10),

VGBEL1 LIKE LIPS-VGBEL, "SALES ORDER

LTEXT3(9), "C&F SALES INVOICE NO

END OF CUSTTAB.

*

DATA : LINENO LIKE SY-TABIX.

DATA : LINE LIKE SY-TABIX.

data :chk(1).

*

data : begin of errtab occurs 0.

include structure itab.

data : end of errtab.

  • NEW INTERNAL TABLES 20/10/2001 ADDITION END

*

parameters : fname(80) default '/usr/oldtest/salesorder.txt'

lower case.

parameters : fname_d(80) default '/usr/oldtest/errsalesorder.txt'

lower case.

parameters : fname_n(80) default '/usr/oldtest/newsalesorder.txt'

lower case.

parameters : chngfile as checkbox default 'X'.

*

at selection-screen output.

loop at screen.

if screen-name = 'FNAME' or screen-name = 'FNAME_D' or

screen-name = 'FNAME_N' or screen-name = 'CHNGFILE'.

screen-input = '0'.

modify screen.

endif.

endloop.

start-of-selection.

****************************ECC 6.0 Upgrade Change Start ******************************

*

*Modified by : Sanket on : Date:15.11.2007

*

*Commented code : open dataset fname for input in text mode.

*

*

*

*

*

*UCCHECK Error: In "TEXT MODE" the "ENCODING" addition must be specified.

*

*Solution: In words

  • use this statement open dataset <fname> for input in text mode encoding utf-8

*

*Actual (ucommented error free code).

open dataset fname for input in text mode encoding utf-8.

*ENCODING DEFAULT

*WITH SMART LINEFEED.

"encoding utf-8.

*

*

*

***************************ECC 6.0 Upgrade Change End***************************

*open dataset fname for input in text mode.

if sy-subrc eq 0.

do.

clear itab.

read dataset fname into itab.

if sy-subrc <> 0 .

exit.

endif.

append itab.

clear itab.

enddo.

ENDIF.

close dataset fname.

******

  • NEW VALIDATION 20/10/2001 ADDITION START

LOOP AT ITAB.

*

clear chk.

SELECT SINGLE * FROM T001W WHERE WERKS = ITAB-VSTEL1.

IF SY-SUBRC <> 0.

MOVE : ITAB-VSTEL1 TO PLANTTAB-VSTEL1,

ITAB-VGBEL1 TO PLANTTAB-VGBEL1,

ITAB-LTEXT3 TO PLANTTAB-LTEXT3.

COLLECT PLANTTAB.

CLEAR PLANTTAB.

**251001

move : 'X' to chk.

ENDIF.

*

SELECT SINGLE * FROM MARA WHERE MATNR = ITAB-MATNR.

IF SY-SUBRC <> 0.

MOVE : ITAB-MATNR TO MATTAB-MATNR,

ITAB-VGBEL1 TO MATTAB-VGBEL1,

ITAB-LTEXT3 TO MATTAB-LTEXT3.

COLLECT MATTAB.

CLEAR MATTAB.

**251001

move : 'X' to chk.

ENDIF.

*

SELECT SINGLE * FROM MCHA WHERE MATNR = ITAB-MATNR AND

WERKS = ITAB-VSTEL1 AND

CHARG = ITAB-CHARG.

IF SY-SUBRC <> 0.

MOVE : ITAB-MATNR TO BATCHTAB-MATNR,

ITAB-VSTEL1 TO BATCHTAB-VSTEL1,

ITAB-CHARG TO BATCHTAB-CHARG,

ITAB-VGBEL1 TO BATCHTAB-VGBEL1,

ITAB-LTEXT3 TO BATCHTAB-LTEXT3.

COLLECT BATCHTAB.

CLEAR BATCHTAB.

**251001

move : 'X' to chk.

ENDIF.

*

if not itab-kunnr is initial.

SELECT SINGLE * FROM KNA1 WHERE KUNNR = ITAB-KUNNR.

IF SY-SUBRC <> 0.

MOVE : ITAB-KUNNR TO CUSTTAB-KUNNR,

ITAB-VGBEL1 TO CUSTTAB-VGBEL1,

ITAB-LTEXT3 TO CUSTTAB-LTEXT3.

COLLECT CUSTTAB.

CLEAR CUSTTAB.

**251001

move : 'X' to chk.

ENDIF.

endif.

*

if chk = 'X'.

if not itab-vkorg is initial.

move itab-ltext3 to header_itab-ltext3.

append header_itab.

clear header_itab.

endif.

move-corresponding itab to errtab.

append errtab.

delete itab.

endif.

*

ENDLOOP.

*

loop at itab.

read table header_itab with key ltext3 = itab-ltext3.

if sy-subrc = 0.

move-corresponding itab to errtab.

append errtab.

delete itab.

endif.

endloop.

*

  • Deleted Records from itab.

DESCRIBE TABLE ERRTAB LINES LINE.

WRITE : 'DELETED RECORDS FROM ITAB.' COLOR 4 ,LINE .

ULINE.

*

LOOP AT ERRTAB.

WRITE : /1 ERRTAB-MATNR,

ERRTAB-CHARG,

ERRTAB-VGBEL1,

ERRTAB-VSTEL1,

ERRTAB-LTEXT3.

ENDLOOP.

*

****************************ECC 6.0 Upgrade Change Start ******************************

*

*Modified by : Sanket on : Date:15.11.2007

*

*Commented code : open dataset fname_d for output in text mode.

*

*

*

*

*

*UCCHECK Error: In "TEXT MODE" the "ENCODING" addition must be specified.

*

*Solution: In words

  • use this statement open dataset <fname_d> for output in text mode encoding utf-8

*

*Actual (ucommented error free code).

open dataset fname_d for output in text mode encoding utf-8.

*

*

*

***************************ECC 6.0 Upgrade Change End***************************

*open dataset fname_d for output in text mode.

loop at errtab.

transfer errtab to fname_d.

endloop.

close dataset fname_d.

*

if not chngfile is initial.

****************************ECC 6.0 Upgrade Change Start ******************************

*

*Modified by : Sanket on : Date:03.10.2007

*

*Commented code : open dataset fname_n for output in text mode.

*

*

*

*

*

*UCCHECK Error: In "TEXT MODE" the "ENCODING" addition must be specified.

*

*Solution: In words

  • use this statement open dataset <fname_n> for output in text mode encoding utf-8

*

*Actual (ucommented error free code).

open dataset fname_n for output in text mode encoding utf-8.

*

*

*

***************************ECC 6.0 Upgrade Change End***************************

  • open dataset fname_n for output in text mode.

loop at itab.

transfer itab to fname_n.

endloop.

close dataset fname_n.

endif.

  • WRITE MISSING PLANTS

DESCRIBE TABLE PLANTTAB LINES LINENO.

IF LINENO > 0.

WRITE : /1 'Missing plants.' COLOR 4.

ULINE.

SORT PLANTTAB.

LOOP AT PLANTTAB.

WRITE : /1 PLANTTAB-VSTEL1 COLOR 2,

PLANTTAB-VGBEL1 COLOR 2,

PLANTTAB-LTEXT3 COLOR 2.

ENDLOOP.

ELSE.

WRITE : /1 'No plants missing.'.

ENDIF.

*

*

  • WRITE MISSING MATERIALS

DESCRIBE TABLE MATTAB LINES LINENO.

IF LINENO > 0.

WRITE : /1 'Missing materials.' COLOR 4.

ULINE.

SORT MATTAB.

LOOP AT MATTAB.

WRITE : /1 MATTAB-MATNR COLOR 2,

MATTAB-VGBEL1 COLOR 2,

MATTAB-LTEXT3 COLOR 2.

ENDLOOP.

ELSE.

WRITE : /1 'No materials missing.'.

ENDIF.

*

  • WRITE MISSING BATCHES

DESCRIBE TABLE BATCHTAB LINES LINENO.

IF LINENO > 0.

WRITE : /1 'Missing material/plants/batch.' COLOR 4 , LINENO.

ULINE.

SORT BATCHTAB.

LOOP AT BATCHTAB.

WRITE : /1 BATCHTAB-MATNR COLOR 2,

BATCHTAB-VSTEL1 COLOR 2,

BATCHTAB-CHARG COLOR 2,

BATCHTAB-VGBEL1 COLOR 2,

BATCHTAB-LTEXT3 COLOR 2.

ENDLOOP.

ELSE.

WRITE : /1 'No material/plant/batch missing.'.

ENDIF.

*

  • WRITE MISSING BATCHES

DELETE CUSTTAB WHERE KUNNR EQ SPACE.

DESCRIBE TABLE CUSTTAB LINES LINENO.

IF LINENO > 0.

WRITE : /1 'Missing Customers.' COLOR 4.

ULINE.

SORT CUSTTAB.

LOOP AT CUSTTAB.

WRITE : /1 CUSTTAB-KUNNR COLOR 2,

CUSTTAB-VGBEL1 COLOR 2,

CUSTTAB-LTEXT3 COLOR 2.

ENDLOOP.

ELSE.

WRITE : /1 'No Customer missing.'.

ENDIF.

  • NEW VALIDATION 20/10/2001 ADDITION END

Edited by: Asis Mohanty on Feb 13, 2008 7:18 AM

2 REPLIES 2

Former Member
0 Kudos
46

Hi,

i thing this will help u.

REPORT Zxyzzzzzzz.

*REPORT ZDEL_FILE_CREATE_IN_APPLI_SER line-size 400.

*

  • NEW TABLES 20/10/2001 ADDITION START

TABLES : T001W,

MARA,

MCHA,

KNA1.

*

DATA : BEGIN OF ITAB OCCURS 1,

VKORG LIKE VBAK-VKORG , "SALES ORGANIZATION

VTWEG LIKE VBAK-VTWEG, "DISTRIBUTION CHANNEL

DIV(9), "Division Code

VSTEL LIKE LIKP-VSTEL, "SHIPPING POINT EG: CF01

DATBI(19), "SELECTION DATE

VGBEL LIKE LIPS-VGBEL, "SALES ORDER "d

KUNNR(10), "SAP CUSTOMER

MATNR LIKE LIPS-MATNR, "MATL NO "d

CHARG LIKE LIPS-CHARG, "BATCH NO "d

LFIMG(13), "DELIVERY QTY "d

free_qty(13), "not used in SAP "d

LTEXT1(9), "PACKING NO

LTEXT2(9), "ALLOCATION NO

LTEXT3(9), "C&F SALES INVOICE NO "d

VGBEL1 LIKE LIPS-VGBEL, "SALES ORDER "d

VSTEL1 LIKE LIKP-VSTEL, "SHIPPING POINT EG: CF01

DATBI1(19), "SELECTION DATE

END OF ITAB.

data : begin of header_itab occurs 0,

ltext3(9),

end of header_itab.

*******add on 22.10.01

  • NEW INTERNAL TABLES 20/10/2001 ADDITION START

DATA : BEGIN OF PLANTTAB OCCURS 1,

VSTEL1 LIKE LIKP-VSTEL, "SHIPPING POINT EG: CF01

VGBEL1 LIKE LIPS-VGBEL, "SALES ORDER

LTEXT3(9), "C&F SALES INVOICE NO

END OF PLANTTAB.

*

DATA : BEGIN OF MATTAB OCCURS 1,

MATNR LIKE LIPS-MATNR, "MATL NO

VGBEL1 LIKE LIPS-VGBEL, "SALES ORDER

LTEXT3(9), "C&F SALES INVOICE NO

END OF MATTAB.

*

DATA : BEGIN OF BATCHTAB OCCURS 1,

MATNR LIKE LIPS-MATNR, "MATL NO

VSTEL1 LIKE LIKP-VSTEL, "SHIPPING POINT EG: CF01

CHARG LIKE LIPS-CHARG, "BATCH NO

VGBEL1 LIKE LIPS-VGBEL, "SALES ORDER

LTEXT3(9), "C&F SALES INVOICE NO

END OF BATCHTAB.

*

DATA : BEGIN OF CUSTTAB OCCURS 1,

KUNNR(10),

VGBEL1 LIKE LIPS-VGBEL, "SALES ORDER

LTEXT3(9), "C&F SALES INVOICE NO

END OF CUSTTAB.

*

DATA : LINENO LIKE SY-TABIX.

DATA : LINE LIKE SY-TABIX.

data :chk(1).

*

data : begin of errtab occurs 0.

include structure itab.

data : end of errtab.

  • NEW INTERNAL TABLES 20/10/2001 ADDITION END

*

parameters : fname(80) default '/usr/oldtest/salesorder.txt'

lower case.

parameters : fname_d(80) default '/usr/oldtest/errsalesorder.txt'

lower case.

parameters : fname_n(80) default '/usr/oldtest/newsalesorder.txt'

lower case.

parameters : chngfile as checkbox default 'X'.

*

at selection-screen output.

loop at screen.

if screen-name = 'FNAME' or screen-name = 'FNAME_D' or

screen-name = 'FNAME_N' or screen-name = 'CHNGFILE'.

screen-input = '0'.

modify screen.

endif.

endloop.

start-of-selection.

****************************ECC 6.0 Upgrade Change Start ******************************

*

*Modified by : Sanket on : Date:15.11.2007

*

*Commented code : open dataset fname for input in text mode.

*

*

*

*

*

*UCCHECK Error: In "TEXT MODE" the "ENCODING" addition must be specified.

*

*Solution: In words

  • use this statement open dataset <fname> for input in text mode encoding utf-8

*

*Actual (ucommented error free code).

open dataset fname for input in text mode encoding utf-8.

*ENCODING DEFAULT

*WITH SMART LINEFEED.

"encoding utf-8.

*

*

*

***************************ECC 6.0 Upgrade Change End***************************

*open dataset fname for input in text mode.

if sy-subrc eq 0.

do.

clear itab.

read dataset fname into itab.

if sy-subrc <> 0 .

exit.

endif.

append itab.

clear itab.

enddo.

ENDIF.

close dataset fname.

******

  • NEW VALIDATION 20/10/2001 ADDITION START

LOOP AT ITAB.

*

clear chk.

SELECT SINGLE * FROM T001W WHERE WERKS = ITAB-VSTEL1.

IF SY-SUBRC <> 0.

MOVE : ITAB-VSTEL1 TO PLANTTAB-VSTEL1,

ITAB-VGBEL1 TO PLANTTAB-VGBEL1,

ITAB-LTEXT3 TO PLANTTAB-LTEXT3.

COLLECT PLANTTAB.

CLEAR PLANTTAB.

**251001

move : 'X' to chk.

ENDIF.

*

SELECT SINGLE * FROM MARA WHERE MATNR = ITAB-MATNR.

IF SY-SUBRC <> 0.

MOVE : ITAB-MATNR TO MATTAB-MATNR,

ITAB-VGBEL1 TO MATTAB-VGBEL1,

ITAB-LTEXT3 TO MATTAB-LTEXT3.

COLLECT MATTAB.

CLEAR MATTAB.

**251001

move : 'X' to chk.

ENDIF.

*

SELECT SINGLE * FROM MCHA WHERE MATNR = ITAB-MATNR AND

WERKS = ITAB-VSTEL1 AND

CHARG = ITAB-CHARG.

IF SY-SUBRC <> 0.

MOVE : ITAB-MATNR TO BATCHTAB-MATNR,

ITAB-VSTEL1 TO BATCHTAB-VSTEL1,

ITAB-CHARG TO BATCHTAB-CHARG,

ITAB-VGBEL1 TO BATCHTAB-VGBEL1,

ITAB-LTEXT3 TO BATCHTAB-LTEXT3.

COLLECT BATCHTAB.

CLEAR BATCHTAB.

**251001

move : 'X' to chk.

ENDIF.

*

if not itab-kunnr is initial.

SELECT SINGLE * FROM KNA1 WHERE KUNNR = ITAB-KUNNR.

IF SY-SUBRC <> 0.

MOVE : ITAB-KUNNR TO CUSTTAB-KUNNR,

ITAB-VGBEL1 TO CUSTTAB-VGBEL1,

ITAB-LTEXT3 TO CUSTTAB-LTEXT3.

COLLECT CUSTTAB.

CLEAR CUSTTAB.

**251001

move : 'X' to chk.

ENDIF.

endif.

*

if chk = 'X'.

if not itab-vkorg is initial.

move itab-ltext3 to header_itab-ltext3.

append header_itab.

clear header_itab.

endif.

move-corresponding itab to errtab.

append errtab.

delete itab.

endif.

*

ENDLOOP.

*

loop at itab.

read table header_itab with key ltext3 = itab-ltext3.

if sy-subrc = 0.

move-corresponding itab to errtab.

append errtab.

delete itab.

endif.

endloop.

*

  • Deleted Records from itab.

DESCRIBE TABLE ERRTAB LINES LINE.

WRITE : 'DELETED RECORDS FROM ITAB.' COLOR 4 ,LINE .

ULINE.

*

LOOP AT ERRTAB.

WRITE : /1 ERRTAB-MATNR,

ERRTAB-CHARG,

ERRTAB-VGBEL1,

ERRTAB-VSTEL1,

ERRTAB-LTEXT3.

ENDLOOP.

*

****************************ECC 6.0 Upgrade Change Start ******************************

*

*Modified by : Sanket on : Date:15.11.2007

*

*Commented code : open dataset fname_d for output in text mode.

*

*

*

*

*

*UCCHECK Error: In "TEXT MODE" the "ENCODING" addition must be specified.

*

*Solution: In words

  • use this statement open dataset <fname_d> for output in text mode encoding utf-8

*

*Actual (ucommented error free code).

open dataset fname_d for output in text mode encoding utf-8.

*

*

*

***************************ECC 6.0 Upgrade Change End***************************

*open dataset fname_d for output in text mode.

loop at errtab.

transfer errtab to fname_d.

endloop.

close dataset fname_d.

*

if not chngfile is initial.

****************************ECC 6.0 Upgrade Change Start ******************************

*

*Modified by : Sanket on : Date:03.10.2007

*

*Commented code : open dataset fname_n for output in text mode.

*

*

*

*

*

*UCCHECK Error: In "TEXT MODE" the "ENCODING" addition must be specified.

*

*Solution: In words

  • use this statement open dataset <fname_n> for output in text mode encoding utf-8

*

*Actual (ucommented error free code).

open dataset fname_n for output in text mode encoding utf-8.

*

*

*

***************************ECC 6.0 Upgrade Change End***************************

  • open dataset fname_n for output in text mode.

loop at itab.

transfer itab to fname_n.

endloop.

close dataset fname_n.

endif.

  • WRITE MISSING PLANTS

DESCRIBE TABLE PLANTTAB LINES LINENO.

IF LINENO > 0.

WRITE : /1 'Missing plants.' COLOR 4.

ULINE.

SORT PLANTTAB.

LOOP AT PLANTTAB.

WRITE : /1 PLANTTAB-VSTEL1 COLOR 2,

PLANTTAB-VGBEL1 COLOR 2,

PLANTTAB-LTEXT3 COLOR 2.

ENDLOOP.

ELSE.

WRITE : /1 'No plants missing.'.

ENDIF.

*

*

  • WRITE MISSING MATERIALS

DESCRIBE TABLE MATTAB LINES LINENO.

IF LINENO > 0.

WRITE : /1 'Missing materials.' COLOR 4.

ULINE.

SORT MATTAB.

LOOP AT MATTAB.

WRITE : /1 MATTAB-MATNR COLOR 2,

MATTAB-VGBEL1 COLOR 2,

MATTAB-LTEXT3 COLOR 2.

ENDLOOP.

ELSE.

WRITE : /1 'No materials missing.'.

ENDIF.

*

  • WRITE MISSING BATCHES

DESCRIBE TABLE BATCHTAB LINES LINENO.

IF LINENO > 0.

WRITE : /1 'Missing material/plants/batch.' COLOR 4 , LINENO.

ULINE.

SORT BATCHTAB.

LOOP AT BATCHTAB.

WRITE : /1 BATCHTAB-MATNR COLOR 2,

BATCHTAB-VSTEL1 COLOR 2,

BATCHTAB-CHARG COLOR 2,

BATCHTAB-VGBEL1 COLOR 2,

BATCHTAB-LTEXT3 COLOR 2.

ENDLOOP.

ELSE.

WRITE : /1 'No material/plant/batch missing.'.

ENDIF.

*

  • WRITE MISSING BATCHES

DELETE CUSTTAB WHERE KUNNR EQ SPACE.

DESCRIBE TABLE CUSTTAB LINES LINENO.

IF LINENO > 0.

WRITE : /1 'Missing Customers.' COLOR 4.

ULINE.

SORT CUSTTAB.

LOOP AT CUSTTAB.

WRITE : /1 CUSTTAB-KUNNR COLOR 2,

CUSTTAB-VGBEL1 COLOR 2,

CUSTTAB-LTEXT3 COLOR 2.

ENDLOOP.

ELSE.

WRITE : /1 'No Customer missing.'.

ENDIF.

  • NEW VALIDATION 20/10/2001 ADDITION END

Edited by: Asis Mohanty on Feb 13, 2008 7:18 AM

Former Member
0 Kudos
45

report zmaterial_fert.

selection-screen :begin of block bl1 with frame title text-001.

parameters : p_fname type rlgrap-filename,

p_lgort type rlgrap-filename,

p_update(1) default 'N',

p_bdcgrp(12) default 'MM_MASTER'.

selection-screen end of block bl1.

data: v_chr_opengrp type c,

r_matnr like mara-matnr,

r_werks like marc-werks,

v_str_fname type string.

data : begin of bdc_itab occurs 0.

include structure bdcdata.

data : end of bdc_itab.

data: begin of messtab occurs 0.

include structure bdcmsgcoll.

data: end of messtab.

data: begin of count,

inrec(9) type n, " input I_MATERIAL count

create(9) type n, " create count

error(9) type n, " error count

bdc(9) type n, " count of BDC creates

end of count.

data : begin of i_material occurs 0,

matnr(018) type c, "Material number

mbrsh(001) type c, "Industry sector

mtart(004) type c, "Material type

werks(004) type c, "Plant

lgort(004),

lgnum(004),

vkorg(004),

vtweg(002),

mtpos_mara(004),

spart(002),

dwerk(004),

taxkm(001),

versg(001),

  • MTPOS(004),

maktx(040) type c, "Material description

meins(003) type c, "Base unit of measure

matkl(009) type c, "Material group

bismt(018), "old material code

brgew(017) type c, "Gross weight

gewei(003) type c, "Weight unit

ntgew(017) type c, "Net weight

magrv(004) type c, "Matl grp pack matls

tragr(004), "

ladgr(004),

prctr(007),

  • EKGRP(004),

  • EKWSL(004),

chap(012),

mattype(001),

nogrs(001),

outmat(018),

valid(010),

curr(005),

netdeal(018),

asess(018),

disgr(004),

dismm(002) type c,

dispo(003),

  • LGORT(004),

disls(002),

maabc(001),

lgpro(004),

webaz(003),

lgfsb(004),

plifz(003),

  • STRGR(002),

fhori(003),

sfepr(004),

fevor(003),

sfcpf(006),

beskz(001),

perkz(001),

  • VRMOD(001),

  • VINT1(003),

  • VINT2(003),

  • ALTSL(001),

  • SBDKZ(001),

  • FERVOR(002),

  • SFCPF(006),

stprs(015),

  • AWSLS(006),

mtvfp(002),

  • STGRP(002),

*PRCTR(007),

bklas(004),

vprsv(001),

peinh(006),

*EKALR(015),

verpr(015),

hrkft(002),

*HKMAT,

kosgr(010),

*LOSGR(018),

end of i_material.

at selection-screen on value-request for p_fname.

call function 'KD_GET_FILENAME_ON_F4'

exporting

program_name = 'Z_MM_MATERIAL_UPLOAD'

dynpro_number = '1000'

field_name = 'P_FNAME'

changing

file_name = p_fname.

at selection-screen on value-request for p_lgort.

call function 'KD_GET_FILENAME_ON_F4'

exporting

program_name = 'ZMATERIAL'

dynpro_number = '1000'

field_name = 'P_FNAME'

changing

file_name = p_lgort.

start-of-selection.

if p_fname is initial.

message i016(rp) with 'Please enter a file name'.

leave list-processing.

else.

move p_fname to v_str_fname.

endif.

call function 'GUI_UPLOAD'

exporting

filetype = 'ASC'

filename = v_str_fname

has_field_separator = 'X'

tables

data_tab = i_material

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 i_material.

r_matnr = i_material-matnr.

r_werks = i_material-werks.

add 1 to count-inrec.

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'

i_material-matnr.

perform bdc_field using 'RMMG1-MTART'

i_material-mtart.

perform bdc_field using 'RMMG1-MBRSH'

i_material-mbrsh.

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(02)'

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(03)'

'X'.

*PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(07)'

*'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(08)'

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(05)'

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(06)'

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(04)'

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(09)'

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(10)'

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(11)'

'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(16)'

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(17)'

'X'.

perform bdc_field using 'BDC_OKCODE' '=P+'.

perform bdc_dynpro using 'SAPLMGMM' '0070'.

perform bdc_field using 'BDC_CURSOR'

'MSICHTAUSW-DYTXT(07)'.

perform bdc_field using 'MSICHTAUSW-KZSEL(01)'

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(02)'

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(03)'

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(04)'

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(05)'

'X'.

perform bdc_dynpro using 'SAPLMGMM' '0080'.

perform bdc_field using 'BDC_CURSOR'

'RMMG1-LGNUM'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'RMMG1-WERKS'

i_material-werks.

perform bdc_field using 'RMMG1-LGORT'

i_material-lgort.

perform bdc_field using 'RMMG1-LGNUM'

i_material-lgnum.

perform bdc_field using 'RMMG1-VKORG'

i_material-vkorg.

perform bdc_field using 'RMMG1-VTWEG'

i_material-vtweg.

perform bdc_dynpro using 'SAPLMGMM' '4004'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'MAKT-MAKTX'

i_material-maktx.

perform bdc_field using 'MARA-MEINS'

i_material-meins.

perform bdc_field using 'MARA-MATKL'

i_material-matkl.

perform bdc_field using 'MARA-BISMT'

i_material-bismt.

perform bdc_field using 'MARA-BRGEW'

i_material-brgew.

perform bdc_field using 'MARA-GEWEI'

i_material-gewei.

perform bdc_field using 'MARA-NTGEW'

i_material-ntgew.

perform bdc_field using 'MARA-MAGRV'

i_material-magrv.

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'

i_material-maktx.

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'MAKT-MAKTX'

i_material-maktx.

perform bdc_field using 'MARA-MEINS'

i_material-meins.

perform bdc_field using 'MARA-MATKL'

i_material-matkl.

perform bdc_field using 'MARA-SPART'

i_material-spart.

perform bdc_field using 'MVKE-DWERK'

i_material-dwerk.

perform bdc_field using 'BDC_CURSOR'

'MG03STEUER-TAXKM(01)'.

perform bdc_field using 'MG03STEUER-TAXKM(01)'

i_material-taxkm.

perform bdc_dynpro using 'SAPLMGMM' '4200'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'MAKT-MAKTX'

i_material-maktx.

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'MAKT-MAKTX'

i_material-maktx.

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BDC_CURSOR'

'MAKT-MAKTX'.

perform bdc_field using 'MAKT-MAKTX'

i_material-maktx.

perform bdc_field using 'MARA-MTPOS_MARA'

i_material-mtpos_mara.

perform bdc_field using 'MVKE-versg'

i_material-versg.

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BDC_CURSOR'

'MAKT-MAKTX'.

perform bdc_field using 'MAKT-MAKTX'

i_material-maktx.

perform bdc_field using 'MARA-BRGEW'

i_material-brgew.

perform bdc_field using 'MARA-GEWEI'

i_material-gewei.

perform bdc_field using 'MARA-NTGEW'

i_material-ntgew.

perform bdc_field using 'BDC_CURSOR'

'MARA-MAGRV'.

perform bdc_field using 'MARA-MAGRV'

i_material-magrv.

perform bdc_field using 'MARA-TRAGR'

i_material-tragr.

perform bdc_field using 'MARC-LADGR'

i_material-ladgr.

perform bdc_field using 'MARC-PRCTR'

i_material-prctr.

perform bdc_field using 'MARC-MTVFP'

i_material-mtvfp.

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'

i_material-maktx.

perform bdc_field using 'BDC_CURSOR'

'J_1IASSVAL-J_1IVALASS'.

perform bdc_field using 'J_1IMTCHID-J_1ICHID'

i_material-chap.

perform bdc_field using 'J_1IMTCHID-J_1ISUBIND'

'X'..

perform bdc_field using 'J_1IMTCHID-J_1ICAPIND'

i_material-mattype.

perform bdc_field using 'J_1IMTCHID-J_1IGRXREF'

i_material-nogrs.

perform bdc_field using 'J_1IMODDET-J_1IMOOM'

i_material-outmat.

perform bdc_field using 'J_1IASSVAL-J_1IFRDATE'

i_material-valid.

perform bdc_field using 'J_1IASSVAL-J_1IWAERS'

i_material-curr.

perform bdc_field using 'J_1IASSVAL-J_1IVALNDP'

i_material-netdeal.

perform bdc_field using 'J_1IASSVAL-J_1IVALASS'

i_material-asess.

*perform bdc_dynpro using 'SAPLMGMM' '4000'.

*perform bdc_field using 'BDC_OKCODE'

  • '/00'.

*perform bdc_field using 'BDC_CURSOR'

  • 'MAKT-MAKTX'.

*perform bdc_field using 'MAKT-MAKTX'

  • I_MATERIAL-MAKTX.

*perform bdc_field using 'MVKE-MTPOS'

  • I_MATERIAL-MTPOS.

*

*

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'ENTR'.

perform bdc_field using 'MAKT-MAKTX'

i_material-maktx.

perform bdc_field using 'MARA-MEINS'

i_material-meins.

perform bdc_field using 'BDC_CURSOR'

'MARC-DISMM'.

perform bdc_field using 'MARC-DISMM'

i_material-dismm.

perform bdc_field using 'MARC-DISPO'

i_material-dispo.

perform bdc_field using 'MARC-DISLS'

i_material-disls.

perform bdc_field using 'MARC-MAABC'

i_material-maabc.

perform bdc_field using 'MARC-DISGR'

i_material-disgr.

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'MAKT-MAKTX'

i_material-maktx.

perform bdc_field using 'MARC-FHORI'

i_material-fhori.

perform bdc_field using 'MARC-LGPRO'

i_material-lgpro.

perform bdc_field using 'MARC-LGFSB'

i_material-lgfsb.

perform bdc_field using 'MARC-PLIFZ'

i_material-plifz.

*perform bdc_field using 'MARC-STRGR'

  • I_MATERIAL-STRGR.

perform bdc_field using 'MARC-BESKZ'

i_material-beskz.

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BDC_CURSOR'

'MAKT-MAKTX'.

perform bdc_field using 'MAKT-MAKTX'

i_material-maktx.

*perform bdc_field using 'MARC-STRGR'

  • I_MATERIAL-STRGR.

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BDC_CURSOR'

'MAKT-MAKTX'.

perform bdc_field using 'MAKT-MAKTX'

i_material-maktx.

perform bdc_field using 'MARC-SAUFT'

'X'.

perform bdc_field using 'MARC-SFEPR'

i_material-sfepr.

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BDC_CURSOR'

'MAKT-MAKTX'.

perform bdc_field using 'MAKT-MAKTX'

i_material-maktx.

perform bdc_field using 'MArc-FEVOR'

i_material-fevor.

perform bdc_field using 'MARC-SFCPF'

i_material-sfcpf.

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BDC_CURSOR'

'MAKT-MAKTX'.

perform bdc_field using 'MAKT-MAKTX'

i_material-maktx.

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BDC_CURSOR'

'MAKT-MAKTX'.

perform bdc_field using 'MAKT-MAKTX'

i_material-maktx.

*

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BDC_CURSOR'

'MAKT-MAKTX'.

perform bdc_field using 'MAKT-MAKTX'

i_material-maktx.

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BDC_CURSOR'

'MAKT-MAKTX'.

perform bdc_field using 'MAKT-MAKTX'

i_material-maktx.

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BDC_CURSOR'

'MAKT-MAKTX'.

perform bdc_field using 'MAKT-MAKTX'

i_material-maktx.

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BDC_CURSOR'

'MAKT-MAKTX'.

perform bdc_field using 'MAKT-MAKTX'

i_material-maktx.

perform bdc_field using 'BDC_CURSOR'

'MBEW-BKLAS'.

perform bdc_field using 'MBEW-BKLAS'

i_material-bklas.

perform bdc_field using 'MBEW-VPRSV'

i_material-vprsv.

perform bdc_field using 'MBEW-PEINH'

i_material-peinh.

perform bdc_field using 'MBEW-STPRS'

i_material-stprs.

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BDC_CURSOR'

'MAKT-MAKTX'.

perform bdc_field using 'MAKT-MAKTX'

i_material-maktx.

*

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BDC_CURSOR'

'MAKT-MAKTX'.

perform bdc_field using 'MAKT-MAKTX'

i_material-maktx.

perform bdc_field using 'Mbew-kosgr'

i_material-kosgr.

perform bdc_field using 'Mbew-HKMAT'

'X'.

perform bdc_field using 'Mbew-HRKFT'

i_material-hrkft.

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BDC_CURSOR'

'MAKT-MAKTX'.

perform bdc_field using 'MAKT-MAKTX'

i_material-maktx.

*perform bdc_field using 'Mbew-KOSGR'

  • I_MATERIAL-KOSGR.

*

perform bdc_dynpro using 'SAPLSPO1' '0300'.

perform bdc_field using 'BDC_OKCODE'

'=YES'.

perform post_transaction.

refresh bdc_itab.

clear bdc_itab.

endloop.

end-of-selection.

perform finalization.

----


  • Start new screen *

----


form bdc_dynpro using program dynpro.

clear bdc_itab.

bdc_itab-program = program.

bdc_itab-dynpro = dynpro.

bdc_itab-dynbegin = 'X'.

append bdc_itab.

endform. "bdc_dynpro

----


  • Insert field *

----


form bdc_field using fnam fval.

if fval <> ''.

clear bdc_itab.

bdc_itab-fnam = fnam.

bdc_itab-fval = fval.

append bdc_itab.

endif.

endform. "bdc_field

&----


*& Form POST_TRANSACTION

----


form post_transaction.

refresh messtab.

clear messtab.

call transaction 'MM01' using bdc_itab

mode p_update

update 'S'

messages into messtab.

submit zrpt_plantext with flatfile = p_lgort

with p_matnr = r_matnr

with p_werks = r_werks and return.

read table messtab with key msgtyp = 'E'.

if sy-subrc eq 0.

perform process_error_messages.

add 1 to count-bdc.

if v_chr_opengrp is initial.

perform bdc_open_group.

endif.

call function 'BDC_INSERT'

exporting

tcode = 'MM01'

tables

dynprotab = bdc_itab

exceptions

internal_error = 1

not_open = 2

queue_error = 3

tcode_invalid = 4

others = 5.

if sy-subrc <> 0.

case sy-subrc.

when 1.

write: / 'Internal error'.

when 2.

write: / 'Not open error'.

when 3.

write: / 'queue error'.

when 4.

write: / 'tcode invalid error'.

when others.

write: / 'other error'.

endcase.

endif.

else.

add +1 to count-create.

format intensified off.

format color col_normal.

format color col_normal off.

endif.

clear bdc_itab.

refresh bdc_itab.

endform. " POST_TRANSACTION

&----


*& Form PROCESS_ERROR_MESSAGES

----


form process_error_messages.

data: begin of loc_aux_message.

include structure message.

data: end of loc_aux_message.

data : msgno type sy-msgno.

loop at messtab.

move messtab-msgnr to msgno.

call function 'WRITE_MESSAGE'

exporting

msgid = messtab-msgid

msgno = msgno

msgty = messtab-msgtyp

msgv1 = messtab-msgv1

msgv2 = messtab-msgv2

msgv3 = messtab-msgv3

msgv4 = messtab-msgv4

importing

messg = loc_aux_message

exceptions

others = 1.

if sy-subrc eq 0.

format color col_negative on.

write: /10 i_material-matnr.

write: /10 loc_aux_message.

format color col_negative off.

else.

format color col_negative on.

write: /10 i_material-matnr.

write: / 'Error creating message'.

format color col_negative off.

exit.

endif.

endloop.

endform. " PROCESS_ERROR_MESSAGES

&----


*& Form BDC_OPEN_GROUP

----


form bdc_open_group.

call function 'BDC_OPEN_GROUP'

exporting

client = sy-mandt

group = p_bdcgrp

holddate = sy-datum

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.

if sy-subrc eq 0.

v_chr_opengrp = 'X'.

endif.

endform. " BDC_OPEN_GROUP

&----


*& Form FINALIZATION

&----


form finalization.

if v_chr_opengrp = 'X'.

call function 'BDC_CLOSE_GROUP'

exceptions

not_open = 1

queue_error = 2

others = 3.

endif.

get time.

skip 2.

write: / 'Time', sy-uzeit.

skip.

format color col_total on.

write: / 'Total Records: ', 40 count-inrec.

write: / 'PERNR not of Emp Group 6 ', 40 count-error.

write: / 'Records Created: ', 40 count-create.

write: / 'BDC Create in group: ', 40 count-bdc.

if v_chr_opengrp = 'X'.

skip 1.

format intensified on.

format color col_negative on.

write: / 'PLEASE USE TRANSACTION "SM35" ',

'TO PROCESS THE GENERATED BDC SESSION ... ',

p_bdcgrp.

endif.

endform. " FINALIZATION