Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

MM01 QM view

Hi guys ,

i am uploading Material master Qm view,

when i am entering material no and enter its not selecting any QM View, its giving error plz select any View..... i am using both ways but not selcting any views plz can any one give me the solution... this is my code...

REPORT ZFINAL_MMQM1

NO STANDARD PAGE HEADING LINE-SIZE 255.

*include bdcrecx1.

DATA : BEGIN OF IT_UPLOAD OCCURS 0,

MATNR(18), " LIKE RMMG1-MATNR, "Material

MBRSH(1), " LIKE RMMG1-MBRSH, "Indusector

MTART(4), " LIKE RMMG1-MTART, "Material Type

WERKS LIKE MARC-WERKS, "Plant

AUSME LIKE MARC-AUSME, "

INSMK LIKE MARC-INSMK, "

QMATA LIKE MARC-QMATA, "

KZDKZ LIKE MARC-KZDKZ, "

WEBAZ LIKE MARC-WEBAZ, "

PRFRQ LIKE MARC-PRFRQ, "

RBNRM LIKE MARA-RBNRM, "

MMSTA LIKE MARC-MMSTA, "

MMSTD LIKE MARC-MMSTD, "

QMPUR LIKE MARA-QMPUR, "

SSQSS LIKE MARC-SSQSS, "

QZGTP LIKE MARC-QZGTP, "

QSSYS LIKE MARC-QSSYS, "

ART LIKE RMQAM-ART(01), "

AKTIV LIKE RMQAM-AKTIV(01),"

END OF IT_UPLOAD.

DATA : BEGIN OF IT_UPLOAD_ERR OCCURS 0,

MATNR(18), " LIKE RMMG1-MATNR, "Material

MBRSH(1), " LIKE RMMG1-MBRSH, "Indusector

MTART(4), " LIKE RMMG1-MTART, "Material Type

WERKS LIKE MARC-WERKS, "Plant

AUSME LIKE MARC-AUSME, "

INSMK LIKE MARC-INSMK, "

QMATA LIKE MARC-QMATA, "

KZDKZ LIKE MARC-KZDKZ, "

WEBAZ LIKE MARC-WEBAZ, "

PRFRQ LIKE MARC-PRFRQ, "

RBNRM LIKE MARA-RBNRM, "

MMSTA LIKE MARC-MMSTA, "

MMSTD LIKE MARC-MMSTD, "

QMPUR LIKE MARA-QMPUR, "

SSQSS LIKE MARC-SSQSS, "

QZGTP LIKE MARC-QZGTP, "

QSSYS LIKE MARC-QSSYS, "

ART LIKE RMQAM-ART(01), "

AKTIV LIKE RMQAM-AKTIV(01), "

END OF IT_UPLOAD_ERR.

DATA : V_PATH TYPE STRING.

DATA V_MTART LIKE MARA-MTART.

DATA V_FLAG.

DATA V_SELECTION TYPE STRING. " For View Selection

FIELD-SYMBOLS : <FS> TYPE ANY.

DATA : IT_DATA(100) OCCURS 0 WITH HEADER LINE,

IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE,

IT_BDCDATA_VIEW LIKE BDCDATA OCCURS 0 WITH HEADER LINE,

IT_FIELD(100) OCCURS 0 WITH HEADER LINE,

IT_BDCMSG LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.

----


  • Selection Screen *

----


SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

SELECTION-SCREEN SKIP 1.

SELECTION-SCREEN ULINE.

PARAMETERS : P_PATH LIKE RLGRAP-FILENAME OBLIGATORY

DEFAULT 'D:\Documents and Settings\277512\Desktop\QM.txt'.

*PARAMETERS p_sel TYPE zmode DEFAULT 'A'.

SELECTION-SCREEN ULINE.

SELECTION-SCREEN SKIP 1.

SELECTION-SCREEN END OF BLOCK B1.

----


  • At Selection Screen *

----


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.

----


  • Start of Selection *

----


START-OF-SELECTION.

V_PATH = P_PATH.

PERFORM UPLOAD_INTERNAL_TABLE.

PERFORM FILL_BDCDATA.

&----


*& Form upload_internal_table

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM UPLOAD_INTERNAL_TABLE .

  • UPLOADING THE FILE.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = V_PATH

TABLES

DATA_TAB = IT_DATA.

IF SY-SUBRC <> 0.

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

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

ENDIF.

PERFORM FORMAT_FILE_READ.

ENDFORM. " upload_internal_table

&----


*& Form format_file_read

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM FORMAT_FILE_READ .

LOOP AT IT_DATA.

SPLIT IT_DATA AT CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB INTO

TABLE IT_FIELD.

LOOP AT IT_FIELD.

IF NOT IT_FIELD IS INITIAL.

ASSIGN COMPONENT SY-TABIX OF STRUCTURE IT_UPLOAD TO <FS>.

<FS> = IT_FIELD.

ENDIF.

ENDLOOP.

APPEND IT_UPLOAD.

CLEAR: IT_FIELD ,IT_UPLOAD .

REFRESH : IT_FIELD.

ENDLOOP.

ENDFORM. " format_file_read

&----


*& Form fill_bdcdata

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM FILL_BDCDATA .

  • DATA : BEGIN OF IT_QMAT OCCURS 0,

  • MATNR LIKE QMAT-MATNR,

  • WERKS LIKE QMAT-WERKS,

  • ART LIKE QMAT-ART,

  • END OF IT_QMAT.

LOOP AT IT_UPLOAD.

REFRESH IT_BDCDATA.

CLEAR V_MTART.

If it_upload is not INITIAL.

PERFORM CONV_MATNR_INTO_PROPER_FORMAT .

TRANSLATE IT_UPLOAD-MATNR TO UPPER CASE.

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'

IT_UPLOAD-MATNR. " 'KANROH1'.

  • SELECT MTART FROM MARA INTO V_MTART

  • WHERE MATNR = IT_UPLOAD-MATNR.

  • ENDSELECT.

PERFORM BDC_FIELD USING 'RMMG1-MBRSH'

IT_UPLOAD-MBRSH. " 'M'.

PERFORM BDC_FIELD USING 'RMMG1-MTART'

IT_UPLOAD-MTART. " 'FERT'.

  • CALL FUNCTION 'MATERIAL_BTCI_SELECTION_NEW' " Function module for getting all view's for the particular material into internal table..

  • EXPORTING

  • MATERIAL = IT_UPLOAD-MATNR " Material number

  • MATERIALART = V_MTART " Material Type

  • SELECTION = 'Q' " PSTAT(maintenance status) value for Quality Managemant.

  • TCODE = 'MM01' " Tcode where view's are called.

  • TABLES

  • BTCI_D0070 = IT_BDCDATA_VIEW

  • EXCEPTIONS

  • MATERIAL_NOT_FOUND = 1

  • MATERIAL_NUMBER_MISSING = 2

  • MATERIAL_TYPE_MISSING = 3

  • MATERIAL_TYPE_NOT_FOUND = 4

  • NO_ACTIVE_DYNPRO_SELECTED = 5

  • NO_AUTHORITY = 6

  • OTHERS = 7.

*

  • READ TABLE IT_BDCDATA_VIEW WITH KEY FVAL = 'X'.

  • IF SY-SUBRC = 0.

  • V_SELECTION = IT_BDCDATA_VIEW-FNAM.

  • ENDIF.

PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0070'.

PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(22)'

'X'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'MSICHTAUSW-DYTXT(22)'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=ENTR'.

PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0060'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'SP15'.

*

  • PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0070'.

  • PERFORM BDC_FIELD USING 'BDC_CURSOR'

  • V_SELECTION. " 'MSICHTAUSW-DYTXT(22)'.

  • PERFORM BDC_FIELD USING 'BDC_OKCODE'

  • '=ENTR'.

  • PERFORM BDC_FIELD USING V_SELECTION " 'MSICHTAUSW-KZSEL(22)'

  • 'X'.

  • PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0070'.

  • PERFORM BDC_FIELD USING 'BDC_CURSOR'

  • 'MSICHTAUSW-DYTXT(01)'. " V_SELECTION.

  • PERFORM BDC_FIELD USING 'BDC_OKCODE'

  • '/00'.

*

  • PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0070'.

  • PERFORM BDC_FIELD USING 'BDC_CURSOR'

  • 'MSICHTAUSW-DYTXT(01)'. " V_SELECTION. "

  • PERFORM BDC_FIELD USING 'BDC_OKCODE'

  • '/00'.

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'

IT_UPLOAD-WERKS. "'12p1'.

PERFORM BDC_DYNPRO USING 'SAPLMGMM' '4000'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=PB01'.

PERFORM BDC_FIELD USING 'MAKT-MAKTX'

'UPOWER_H'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'MARC-MMSTD'.

PERFORM BDC_FIELD USING 'MARC-AUSME'

IT_UPLOAD-AUSME. " ''.

PERFORM BDC_FIELD USING 'MARC-INSMK'

IT_UPLOAD-INSMK. " ''.

PERFORM BDC_FIELD USING 'MARC-QMATA'

IT_UPLOAD-QMATA. " '000010'.

PERFORM BDC_FIELD USING 'MARC-KZDKZ'

IT_UPLOAD-KZDKZ. " ''.

PERFORM BDC_FIELD USING 'MARC-WEBAZ'

IT_UPLOAD-WEBAZ. " '0'.

PERFORM BDC_FIELD USING 'MARC-PRFRQ'

IT_UPLOAD-PRFRQ. " ''.

PERFORM BDC_FIELD USING 'MARA-RBNRM'

IT_UPLOAD-RBNRM. " ''.

PERFORM BDC_FIELD USING 'MARC-MMSTA'

IT_UPLOAD-MMSTA. " ''.

PERFORM BDC_FIELD USING 'MARC-MMSTD'

IT_UPLOAD-MMSTD. " ''.

PERFORM BDC_FIELD USING 'MARA-QMPUR'

IT_UPLOAD-QMPUR. " 'X'.

PERFORM BDC_FIELD USING 'MARC-SSQSS'

IT_UPLOAD-SSQSS. " '0001'.

PERFORM BDC_FIELD USING 'MARC-QZGTP'

IT_UPLOAD-QZGTP. " ''.

PERFORM BDC_FIELD USING 'MARC-QSSYS'

IT_UPLOAD-QSSYS. " ''.

PERFORM BDC_DYNPRO USING 'SAPLQPLS' '0100'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'RMQAM-ARGUMENT'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=NEU'.

PERFORM BDC_DYNPRO USING 'SAPLQPLS' '0100'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'RMQAM-AKTIV(01)'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=WEIT'.

PERFORM BDC_FIELD USING 'RMQAM-ART(01)'

IT_UPLOAD-ART. " '01'.

PERFORM BDC_FIELD USING 'RMQAM-AKTIV(01)'

IT_UPLOAD-AKTIV. " 'X'.

PERFORM BDC_DYNPRO USING 'SAPLMGMM' '4000'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=BU'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'MAKT-MAKTX'.

PERFORM BDC_FIELD USING 'MAKT-MAKTX'

'UPOWER_H'.

PERFORM BDC_FIELD USING 'MARC-QMATA'

IT_UPLOAD-QMATA. " '000010'.

PERFORM BDC_FIELD USING 'MARA-QMPUR'

IT_UPLOAD-QMPUR. " 'X'.

PERFORM BDC_FIELD USING 'MARC-SSQSS'

IT_UPLOAD-SSQSS. " '0001'.

PERFORM BDC_DYNPRO USING 'SAPLSPO1' '0300'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=YES'.

CALL TRANSACTION 'MM01' USING IT_BDCDATA MODE 'A' MESSAGES INTO IT_BDCMSG.

  • p_sel MESSAGES INTO it_bdcmsg.

IF SY-SUBRC <> 0.

MOVE-CORRESPONDING IT_UPLOAD TO IT_UPLOAD_ERR.

APPEND IT_UPLOAD_ERR.

WRITE :/ 'Data is not uploaded for the material :', IT_UPLOAD-MATNR.

*--


RG-001--


Start.

  • ELSE.

  • WRITE :/ 'Data is uploaded sucessfully for the material :', it_upload-matnr.

*--


RG-001--


End.

ENDIF.

ENDIF.

ENDLOOP.

IF IT_UPLOAD_ERR[] IS NOT INITIAL.

CALL FUNCTION 'DOWNLOAD'

EXPORTING

FILENAME = ' '

FILETYPE = 'DAT'

TABLES

DATA_TAB = IT_UPLOAD_ERR.

IF SY-SUBRC <> 0.

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

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

ENDIF.

ELSE.

WRITE :/ 'Data is uploaded sucessfully for all materials.'.

ENDIF.

ENDFORM. "FILL_BDCDATA

----


  • Start new screen *

----


FORM BDC_DYNPRO USING PROGRAM DYNPRO.

CLEAR IT_BDCDATA.

IT_BDCDATA-PROGRAM = PROGRAM.

IT_BDCDATA-DYNPRO = DYNPRO.

IT_BDCDATA-DYNBEGIN = 'X'.

APPEND IT_BDCDATA.

ENDFORM. "BDC_DYNPRO

----


  • Insert field *

----


FORM BDC_FIELD USING FNAM FVAL.

IF FVAL <> SPACE.

CLEAR IT_BDCDATA.

IT_BDCDATA-FNAM = FNAM.

IT_BDCDATA-FVAL = FVAL.

APPEND IT_BDCDATA.

ENDIF.

ENDFORM. "BDC_FIELD

&----


*& Form conv_matnr_into_proper_format

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM CONV_MATNR_INTO_PROPER_FORMAT .

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = IT_UPLOAD-MATNR

IMPORTING

OUTPUT = IT_UPLOAD-MATNR

EXCEPTIONS

OTHERS = 1.

ENDFORM.

Former Member
Not what you were looking for? View more on this topic or Ask a question