SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Finding Where the material is used.



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> PP
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sun Dec 16, 2007 6:53 pm    Post subject: Finding Where the material is used. Reply with quote

Code:
TABLES : marc.
TYPE-POOLS : slis.

DATA: BEGIN OF g_t_final OCCURS 0,
werks LIKE marc-werks,
matnr LIKE marc-matnr,
comp LIKE marc-matnr,
level LIKE stpov-level,
END OF g_t_final.

DATA : g_t_fieldcat TYPE slis_t_fieldcat_alv.

DATA : g_t_marc LIKE marc OCCURS 0 WITH HEADER LINE.

SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-000.
PARAMETERS : p_werks LIKE marc-werks.
SELECT-OPTIONS : s_matnr FOR marc-matnr.
SELECTION-SCREEN END OF BLOCK blk1.

PERFORM : get_ss_components,
search_components,
display.

*&---------------------------------------------------------------------*
*& Form get_ss_components
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
<-- p2 text
*----------------------------------------------------------------------*
FORM get_ss_components.

SELECT * FROM marc INTO TABLE g_t_marc WHERE matnr IN s_matnr
AND werks = p_werks.

ENDFORM. " get_ss_components
*&---------------------------------------------------------------------*
*& Form search_components
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
<-- p2 text
*----------------------------------------------------------------------*
FORM search_components.

DATA : l_t_marc LIKE marc OCCURS 0 WITH HEADER LINE,
l_t_final LIKE g_t_final OCCURS 0 WITH HEADER LINE.

DATA : l_t_wultb LIKE stpov OCCURS 0 WITH HEADER LINE,
l_t_equicat LIKE cscequi OCCURS 0 WITH HEADER LINE,
l_t_kndcat LIKE cscknd OCCURS 0 WITH HEADER LINE,
l_t_matcat LIKE cscmat OCCURS 0 WITH HEADER LINE,
l_t_stdcat LIKE cscstd OCCURS 0 WITH HEADER LINE,
l_t_tplcat LIKE csctpl OCCURS 0 WITH HEADER LINE.

DATA : l_f_matnr LIKE mara-matnr,
l_f_num TYPE i VALUE '0'.

l_t_marc[] = g_t_marc[].

CLEAR g_t_marc.
REFRESH g_t_marc[].

DO.
l_f_num = l_f_num + 1.

LOOP AT l_t_marc.

IF l_f_num = 1.
l_f_matnr = l_t_marc-matnr.
ENDIF.

CALL FUNCTION 'CS_WHERE_USED_MAT'
EXPORTING
datub = sy-datum
datuv = sy-datum
matnr = l_t_marc-matnr
stlan = '1'
werks = l_t_marc-werks
TABLES
wultb = l_t_wultb
equicat = l_t_equicat
kndcat = l_t_kndcat
matcat = l_t_matcat
stdcat = l_t_stdcat
tplcat = l_t_tplcat
EXCEPTIONS
call_invalid = 1
material_not_found = 2
no_where_used_rec_found = 3
no_where_used_rec_selected = 4
no_where_used_rec_valid = 5
OTHERS = 6.

IF sy-subrc = 0.

LOOP AT l_t_wultb.

g_t_final-werks = l_t_marc-werks.
g_t_final-matnr = l_f_matnr.
g_t_final-comp = l_t_wultb-matnr.
g_t_final-level = l_f_num.

APPEND g_t_final.
CLEAR g_t_final.

l_t_final-werks = l_t_marc-werks.
l_t_final-comp = l_t_wultb-matnr.

APPEND l_t_final.
CLEAR l_t_final.
ENDLOOP.

ENDIF.

REFRESH : l_t_wultb, l_t_equicat, l_t_kndcat,
l_t_matcat, l_t_stdcat, l_t_tplcat.
CLEAR : l_t_wultb, l_t_equicat, l_t_kndcat,
l_t_matcat, l_t_stdcat, l_t_tplcat.

LOOP AT l_t_final.
g_t_marc-matnr = l_t_final-comp.
g_t_marc-werks = l_t_final-werks.
APPEND g_t_marc.
CLEAR g_t_marc.
ENDLOOP.

CLEAR : l_t_final.
REFRESH : l_t_final[].

ENDLOOP.

CLEAR : l_t_marc[].
REFRESH : l_t_marc[].

l_t_marc[] = g_t_marc[].

CLEAR : g_t_marc.
REFRESH : g_t_marc[].

IF l_t_marc[] IS INITIAL.
EXIT.
ENDIF.

ENDDO.
ENDFORM. " search_components
*&---------------------------------------------------------------------*
*& Form display
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
<-- p2 text
*----------------------------------------------------------------------*
FORM display.

DATA : l_t_fieldcat TYPE slis_t_fieldcat_alv,
l_r_fieldcat LIKE LINE OF l_t_fieldcat,
l_f_repid LIKE sy-repid,
l_r_layout TYPE slis_layout_alv.

IF g_t_final[] IS INITIAL.
MESSAGE i000(vz) WITH 'No data found'.
EXIT.
ELSE.

l_f_repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = l_f_repid
i_internal_tabname = 'G_T_FINAL'
i_client_never_display = 'X'
i_inclname = l_f_repid
CHANGING
ct_fieldcat = g_t_fieldcat[].

LOOP AT g_t_fieldcat INTO l_r_fieldcat.

IF l_r_fieldcat-key = 'X'.
l_r_fieldcat-key = ''.
MODIFY g_t_fieldcat FROM l_r_fieldcat.
ENDIF.

CASE l_r_fieldcat-fieldname.
WHEN 'MATNR'.
l_r_fieldcat-seltext_l = 'Component'.
l_r_fieldcat-seltext_m = 'Component'.
l_r_fieldcat-seltext_s = 'Component'.
MODIFY g_t_fieldcat FROM l_r_fieldcat.
ENDCASE.
ENDLOOP.

*Layout
l_r_layout-zebra = 'X'.
l_r_layout-colwidth_optimize = 'X'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = l_f_repid
is_layout = l_r_layout
it_fieldcat = g_t_fieldcat
i_save = 'X'
TABLES
t_outtab = g_t_final
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.

ENDIF.
ENDFORM. " display


KeyWords: Где используется материал?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> PP All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.