Go on link..

link us with ...

Thursday, December 30, 2010

MASTER MATERAIL DETAILS

*&---------------------------------------------------------------------*
*& Report ZVVF_MR_MAT_DETAIL *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*

REPORT ZVVF_MR_MAT_DETAIL .

TABLES : MARA,MAKT,MARC.

TYPE-POOLS slis.

DATA : BEGIN OF IT_MAIN OCCURS 0,
MATNR LIKE MARA-MATNR,
MAKTX LIKE MAKT-MAKTX,
WERKS LIKE MARC-WERKS,
mtart like mara-mtart,
matkl like mara-matkl,
meins like mara-meins,
W_TDNAME LIKE STXH-TDNAME,
W_DESC(255) TYPE C,
W_DESC1(125) TYPE C,
W_DESC2(125) TYPE C,
W_DESC3(125) TYPE C,

END OF IT_MAIN.
DATA : WS_TDID LIKE STXH-TDID.
data : LW_OUTLEN TYPE I.
*DATA : W_MATNR(10) TYPE C.
DATA : BEGIN OF ST_LINE OCCURS 0,
TDFORMAT LIKE TLINE-TDFORMAT,
TDLINE LIKE TLINE-TDLINE,
END OF ST_LINE.
DATA : W_S TYPE I.

**---------------------------------------------------------------------*
* Constants Begin with C_
**---------------------------------------------------------------------*

CONSTANTS: st_formname_top_of_page TYPE slis_formname
VALUE 'TOP_OF_PAGE-ALV'.
*------------------------------------------------------------------------

**---------------------------------------------------------------------*
* Data Begin with W_
**---------------------------------------------------------------------*

*-------- Declarations for ALV Grid.

DATA: it_st_list_top_of_page TYPE slis_t_listheader,
it_st_fieldcat TYPE slis_t_fieldcat_alv,
it_st_events TYPE slis_t_event,
st_layout TYPE slis_layout_alv,
s_status TYPE slis_formname VALUE 'STANDARD_ST01',
s_user_command TYPE slis_formname VALUE 'USER_COMMAND-ALV',
s_repid LIKE sy-repid,
s_save(1) TYPE c,
s_variant LIKE disvariant,
code LIKE disvariant-handle.


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

SELECTION-SCREEN : SKIP 1.

PARAMETERS : PR_WERKS LIKE MARC-WERKS OBLIGATORY.
SELECT-OPTIONS : SO_MATNR FOR MARA-MATNR,
so_mtart for mara-mtart,
so_matkl for mara-matkl.

SELECTION-SCREEN END OF BLOCK MR1.
**---------------------------------------------------------------------*
* Initialisation
**---------------------------------------------------------------------*

INITIALIZATION.
s_repid = sy-repid.
s_save = 'A'.
PERFORM eventtab_build USING it_st_events[].
PERFORM variant_init.



************************************************************************
* S T A R T O F S E L E C T I O N
************************************************************************
START-OF-SELECTION.

PERFORM POPULATE_DATA.
PERFORM comment_build USING it_st_list_top_of_page[]. "dISPLAY hEADING IN ALV
PERFORM fieldcat USING it_st_fieldcat[]. "PUT DATA IN ALV
PERFORM layout_build USING st_layout.
PERFORM reuse_alv_list_display.

*&--------------------------------------------------------------------*
*& Form POPULATE_DATA
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM POPULATE_DATA.

SELECT a~MATNR a~WERKS b~mtart b~matkl b~meins
INTO CORRESPONDING FIELDS
OF TABLE IT_MAIN
FROM MARC as a inner join mara as b
on a~matnr = b~matnr
WHERE
a~MATNR IN SO_MATNR AND
a~WERKS = PR_WERKS and
mtart in so_mtart and
b~matkl in so_matkl.
LOOP AT IT_MAIN.
SELECT SINGLE MAKTX INTO IT_MAIN-MAKTX FROM MAKT WHERE MATNR = IT_MAIN-MATNR.


IT_MAIN-W_TDNAME = IT_MAIN-MATNR.
W_S = STRLEN( IT_MAIN-W_TDNAME ).

W_S = 18 - W_S.
DO W_S TIMES.
CONCATENATE '0' IT_MAIN-W_TDNAME INTO IT_MAIN-W_TDNAME.
ENDDO.

select single tdid into ws_tdid from stxh
where TDOBJECT = 'MATERIAL' AND TDID = 'BEST' AND TDNAME = IT_MAIN-W_TDNAME.
IF SY-SUBRC = 0.
IF WS_TDID = 'BEST'.
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
id = 'BEST'
language = SY-LANGU
name = IT_MAIN-W_TDNAME
object = 'MATERIAL'
TABLES
lines = ST_LINE
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8.
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 ST_LINE.
CONCATENATE IT_MAIN-W_DESC ST_LINE-TDLINE INTO IT_MAIN-W_DESC.
ENDLOOP.
ENDIF.
ENDIF.
LW_OUTLEN = 125.
CALL FUNCTION 'RKD_WORD_WRAP'
EXPORTING
textline = IT_MAIN-W_DESC
* DELIMITER = ' '
OUTPUTLEN = LW_OUTLEN
IMPORTING
OUT_LINE1 = IT_MAIN-W_DESC1
OUT_LINE2 = IT_MAIN-W_DESC2
OUT_LINE3 = IT_MAIN-W_DESC3
* TABLES
* OUT_LINES =
EXCEPTIONS
OUTPUTLEN_TOO_LARGE = 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.
SHIFT IT_MAIN-W_TDNAME LEFT DELETING LEADING '0'.
MODIFY IT_MAIN.
ENDLOOP.
ENDFORM. "POPULATE_DATA


*&---------------------------------------------------------------------*
*& Form COMMENT_BUILD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM comment_build USING p_it_st_list_top_of_page TYPE slis_t_listheader.

DATA: ls_line TYPE slis_listheader,
mix_date(130) type c,
mix(130) type c,
head_label(130) type c value 'MATERIAL MASTER REPORT'.

REFRESH p_it_st_list_top_of_page.
CLEAR ls_line.
ls_line-typ = 'H'.
ls_line-info = head_label.
APPEND ls_line TO p_it_st_list_top_of_page.

*----- Display Vendor

concatenate 'Plant :' ' ' pr_werks into mix SEPARATED BY SPACE.
ls_line-typ = 'S'.
ls_line-info = mix.
APPEND ls_line TO p_it_st_list_top_of_page.

concatenate 'Material :' ' ' so_matnr-low ' ' so_matnr-high into mix SEPARATED BY SPACE.
ls_line-typ = 'S'.
ls_line-info = mix.
APPEND ls_line TO p_it_st_list_top_of_page.


clear mix.
concatenate 'Material Type :' ' ' so_mtart-low ' ' so_mtart-high into mix SEPARATED BY SPACE.
ls_line-typ = 'S'.
ls_line-info = mix.
APPEND ls_line TO p_it_st_list_top_of_page.

clear mix.
concatenate 'Material Group :' ' ' so_matkl-low ' ' so_matkl-high into mix SEPARATED BY SPACE.
ls_line-typ = 'S'.
ls_line-info = mix.
APPEND ls_line TO p_it_st_list_top_of_page.

clear mix.
ENDFORM. " COMMENT_BUILD



*&--------------------------------------------------------------------*
*& Form TOP_OF_PAGE-ALV
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM top_of_page-alv.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_st_list_top_of_page.

ENDFORM. "TOP_OF_PAGE-ALV



*&---------------------------------------------------------------------*
*& Form FIELDCAT
*&---------------------------------------------------------------------*
* -->P_IT_ST_FIELDCAT[] text
*----------------------------------------------------------------------*
FORM fieldcat USING p_it_st_fieldcat TYPE slis_t_fieldcat_alv.
DATA: ls_fieldcat TYPE slis_fieldcat_alv.



*SALES DOCUMENTS
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'W_TDNAME'.
ls_fieldcat-datatype = 'CHAR'.
ls_fieldcat-outputlen = 18.
ls_fieldcat-seltext_m = 'MATERIAL NO' .
* ls_fieldcat-rollname = 'BELNR'.
ls_fieldcat-key = 'X'.
APPEND ls_fieldcat TO p_it_st_fieldcat.


CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'MAKTX'.
ls_fieldcat-datatype = 'CHAR'.
ls_fieldcat-outputlen = 40.
ls_fieldcat-seltext_m = 'MATERIAL DESCRIPTION' .
* ls_fieldcat-rollname = 'BELNR'.
ls_fieldcat-key = 'X'.
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'W_DESC'.
ls_fieldcat-datatype = 'CHAR'.
ls_fieldcat-outputlen = 250.
ls_fieldcat-seltext_m = 'PURCHASE ORDER TEXT' .
* ls_fieldcat-key = 'X'.
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'MTART'.
ls_fieldcat-datatype = 'CHAR'.
ls_fieldcat-outputlen = 10.
ls_fieldcat-seltext_m = 'MATERIAL TYPE' .
* ls_fieldcat-key = 'X'.
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'MATKL'.
ls_fieldcat-datatype = 'CHAR'.
ls_fieldcat-outputlen = 10.
ls_fieldcat-seltext_m = 'MATERIAL GROUP' .
* ls_fieldcat-key = 'X'.
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'MEINS'.
ls_fieldcat-datatype = 'CHAR'.
ls_fieldcat-outputlen = 4.
ls_fieldcat-seltext_m = 'UNIT OF MEASURE' .
* ls_fieldcat-key = 'X'.
APPEND ls_fieldcat TO p_it_st_fieldcat.




endform.

*&---------------------------------------------------------------------*
*& Form LAYOUT_BUILD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_ST_LAYOUT text
*----------------------------------------------------------------------*
FORM layout_build USING p_st_layout TYPE slis_layout_alv.

p_st_layout-box_fieldname = 'SELK'. " Checkbox
p_st_layout-get_selinfos = 'X'.
p_st_layout-f2code = 'PICK' . " Doppelklickfunktion
p_st_layout-confirmation_prompt = 'X'. "Sicherheitsabfrage
p_st_layout-key_hotspot = 'X'. "Schlüssel als Hotspot
p_st_layout-info_fieldname = 'COL'. "Zeilenfarbe


ENDFORM. " LAYOUT_BUILD




*&---------------------------------------------------------------------*
*& Form REUSE_ALV_LIST_DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM reuse_alv_list_display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = S_REPID
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
I_BACKGROUND_ID = 'ALV_BACKGROUND'
* I_GRID_TITLE =
* I_GRID_SETTINGS =
* IS_LAYOUT =
IT_FIELDCAT = it_st_fieldcat[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS = IT_slis_t_specialcol_alv[]
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
I_SAVE = 'A'
* IS_VARIANT =
IT_EVENTS = IT_ST_EVENTS[]
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_main
EXCEPTIONS
PROGRAM_ERROR = 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. " REUSE_ALV_LIST_DISPLAY



*&---------------------------------------------------------------------*
*& Form EVENTTAB_BUILD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_IT_ST_EVENTS[] text
*----------------------------------------------------------------------*
FORM eventtab_build USING p_st_events TYPE slis_t_event .

DATA: ls_event TYPE slis_alv_event.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = p_st_events.

READ TABLE p_st_events WITH KEY name = slis_ev_top_of_page
INTO ls_event.
IF sy-subrc = 0.
MOVE st_formname_top_of_page TO ls_event-form.
APPEND ls_event TO p_st_events.
ENDIF.



* READ TABLE p_st_events WITH KEY name = slis_ev_pf_status_set
* INTO ls_event.
*
* IF sy-subrc = 0.
* MOVE s_status TO ls_event-form.
* APPEND ls_event TO p_st_events.
* ENDIF.

ENDFORM. " EVENTTAB_BUILD



*&---------------------------------------------------------------------*
*& Form VARIANT_INIT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM variant_init .
CLEAR s_variant.
s_variant-report = s_repid.
s_variant-handle = code.

ENDFORM. " VARIANT_INIT

No comments:

link us...

For Visitors

if you want to publish or Add something on ERP, SAP , SAP FUNCTIONAL, SAP ABAP then mail us along with your email-id. contain must be yours

email-id :- avinashkr_raj@yahoo.com(any email)

email-id :- avinaskr_raj.abap@blogger.com ( use only gmail)