Friday, March 11, 2011

BDC for MEK1 (Condition Records)



REPORT ZMEK1_NEW


NO STANDARD PAGE HEADING LINE-SIZE 255.



START-OF-SELECTION.

type-pools : truxs.



INCLUDE ZBDCRECX1_NEW.



TYPES : BEGIN OF STRUCT,

VEND(7) TYPE C ,

PLANT(4) TYPE C,

MATNR(18) TYPE C,

AMOUNT(16) TYPE C,

UNIT(5) TYPE C,

PER(5) TYPE C,

* CALL(1) TYPE C,

SDAT(10) TYPE C,

EDAT(10) TYPE C,

* EXC(1) TYPE C,

END OF STRUCT.

DATA : ITAB TYPE TABLE OF STRUCT WITH HEADER LINE .

DATA: FILENAM1 TYPE RLGRAP-FILENAME.

*PARAMETERS: FILENAME TYPE STRING.

PARAMETERS : p_path LIKE rlgrap-filename OBLIGATORY.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_PAth.





CALL FUNCTION 'F4_FILENAME'

EXPORTING

program_name = syst-cprog

dynpro_number = syst-dynnr

field_name = ' '

IMPORTING

file_name = p_path.



*CALL FUNCTION 'GUI_FILE_LOAD_DIALOG'

** EXPORTING

** WINDOW_TITLE =

** DEFAULT_EXTENSION =

** DEFAULT_FILE_NAME =

** WITH_ENCODING =

** FILE_FILTER =

** INITIAL_DIRECTORY =

* IMPORTING

** FILENAME =

** PATH =

* FULLPATH = FILENAME

** USER_ACTION =

** FILE_ENCODING =

* .



START-OF-SELECTION.



*v_path = p_path.,





DATA : r_data TYPE truxs_t_text_data.

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

i_line_header = 'X'

i_tab_raw_data = r_data

i_filename = p_path

TABLES

i_tab_converted_data = itab[] .







*CALL FUNCTION 'WS_UPLOAD'

* EXPORTING

** CODEPAGE = ' '

* FILENAME = FILENAM1

* FILETYPE = 'ASC'

** HEADLEN = ' '

** LINE_EXIT = ' '

** TRUNCLEN = ' '

** USER_FORM = ' '

** USER_PROG = ' '

** DAT_D_FORMAT = ' '

** IMPORTING

** FILELENGTH =

* TABLES

* DATA_TAB = ITAB

* 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

* NO_AUTHORITY = 10

* OTHERS = 11

* .

IF SY-SUBRC <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.



data: fnam(200) type c,

fnam1(200) type c,

fnam2(200) type c,

fnam3(200) type c,

fnam4(200) type c,

fnam5(200) type c,

fnam6(200) type c,

fnam7(200) type c,

idx(3) type c.





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'

'ZPB0'.

PERFORM BDC_DYNPRO USING 'SAPLV14A' '0100'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'RV130-SELKZ(04)'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=WEIT'.

PERFORM BDC_FIELD USING 'RV130-SELKZ(01)'

''.

PERFORM BDC_FIELD USING 'RV130-SELKZ(04)'

'X'.



*data: itab1 like table of itab.

*itab1[] = itab[].

move 1 to idx.

LOOP AT itab.



condense idx.



PERFORM BDC_DYNPRO USING 'SAPMV13A' '1599'.

*PERFORM BDC_FIELD USING 'BDC_CURSOR'

* 'KONP-KZNEP(01)'.

*PERFORM BDC_FIELD USING 'BDC_OKCODE'

* '/00'.

PERFORM BDC_FIELD USING 'KOMG-LIFNR'

itab-vend . "'1000006'.

PERFORM BDC_FIELD USING 'KOMG-WERKS'

itab-plant."'2203'.





CONCATENATE 'KOMG-MATNR(' idx ')' into fnam .



PERFORM BDC_FIELD USING fnam

itab-matnr."'2RBOP00001'.



*PERFORM BDC_FIELD USING 'KOMG-MATNR(01)'

* itab-matnr."'2RBOP00001'.

CONCATENATE 'KONP-KBETR(' idx ')' into fnam1 .



PERFORM BDC_FIELD USING fnam1

itab-amount."' 75'.



*PERFORM BDC_FIELD USING 'KONP-KBETR(01)'

* itab-amount."' 75'.



CONCATENATE 'KONP-KONWA(' idx ')' into fnam2 .



PERFORM BDC_FIELD USING fnam2

itab-unit."'inr'.



CONCATENATE 'KONP-KPEIN(' idx ')' into fnam3 .



PERFORM BDC_FIELD USING fnam3

itab-per."' 1'.



CONCATENATE 'RV13A-KRECH(' idx ')' into fnam6 .

PERFORM BDC_FIELD USING fnam6

'C'.





CONCATENATE 'RV13A-DATAB(' idx ')' into fnam4 .



PERFORM BDC_FIELD USING fnam4

itab-sdat."'19.02.2011'.





CONCATENATE 'RV13A-DATBI(' idx ')' into fnam5 .



PERFORM BDC_FIELD USING fnam5

itab-edat."'31.03.2999'.



CONCATENATE 'KONP-KZNEP(' idx ')' into fnam7 .

PERFORM BDC_FIELD USING fnam7

'X'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

*PERFORM BDC_TRANSACTION USING 'MEK1'.

*

*PERFORM CLOSE_GROUP.

at end of vend.

PERFORM BDC_DYNPRO USING 'SAPMV13A' '1599'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'KOMG-MATNR(01)'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=SICH'.



call transaction 'MEK1' using bdcdata mode 'E' .

move 1 to idx.

endat.

idx = idx + 1.

ENDLOOP.

No comments:

Post a Comment