* ---------------------- Internal Tables ---------------------------
DATA: BEGIN OF i_main OCCURS 0,
anagrup LIKE mara-anagrup,
marka LIKE mara-marka,
yil LIKE mara-yil,
sezon LIKE mara-sezon,
grup LIKE mara-grup,
matnr LIKE mara-matnr,
maktx LIKE makt-maktx,
listepsf LIKE mara-zzlstpsf,
lparabir LIKE t001-waers,
zzcins LIKE mara-zzcins,
kbetr LIKE konp-kbetr,
psf_kbetr LIKE konp-kbetr,
maliyet LIKE konp-kbetr,
mparabir LIKE t001-waers,
END OF i_main.
DATA: i_selected_table LIKE i_main OCCURS 0 WITH HEADER LINE.
* BAPI için Malzeme Bilgisini içeren internal table yaratıldı.
DATA: BEGIN OF stabmara OCCURS 0,
sign(01) ,
option(02) ,
low LIKE mara-matnr,
high LIKE mara-matnr,
END OF stabmara.
*---------------------------- Variables ------------------------
DATA: ok_code LIKE sy-ucomm,
save_ok_code LIKE sy-ucomm,
flag(01) ,
l_box(01) .
DATA: index LIKE sy-index,
w_count LIKE sy-index.
DATA: filename LIKE rlgrap-filename,
filetype LIKE rlgrap-filetype,
filelength(5) ,
w_canc(04) .
* ALV
DATA: tb_fieldcat TYPE slis_t_fieldcat_alv,
st_fieldcat_line TYPE slis_fieldcat_alv,
st_layout TYPE slis_layout_alv,
st_print TYPE slis_print_alv,
tb_list_top_of_page TYPE slis_t_listheader,
tb_events TYPE slis_t_event,
tb_sort TYPE slis_t_sortinfo_alv,
tb_header TYPE slis_t_listheader,
st_header_line TYPE slis_listheader.
* BAPI
DATA: returndetail LIKE bapireturn.
DATA: cost_components LIKE bapisplitt OCCURS 0 WITH HEADER LINE.
DATA: returnlist LIKE bapireturn,
cost_estimate_header LIKE bapiheader,
costestimate_list LIKE TABLE OF bapicolist WITH HEADER LINE.
DATA: cost_components_list LIKE cost_estimate_header.
*DATA: BEGIN OF cost_components_list OCCURS 0,
* localprice LIKE mara-zzorfyt.
* INCLUDE STRUCTURE zpc_cost_components_list.
*DATA: END OF cost_components_list.
* Report Selections
SELECTION-SCREEN BEGIN OF BLOCK 0 WITH FRAME TITLE text-0h1.
SELECT-OPTIONS: so_marka FOR mara-marka NO INTERVALS
NO-EXTENSION OBLIGATORY,
so_yil FOR mara-yil NO INTERVALS
NO-EXTENSION OBLIGATORY,
so_sezon FOR mara-sezon NO INTERVALS
NO-EXTENSION OBLIGATORY,
so_grup FOR mara-grup NO INTERVALS
NO-EXTENSION ,
so_matnr FOR bapimateri-low MATCHCODE OBJECT mat1.
SELECTION-SCREEN END OF BLOCK 0.
SELECTION-SCREEN: BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
SELECT-OPTIONS: so_werks FOR bapiplant-low NO-DISPLAY,
so_klvar FOR bapicstgva-low NO-DISPLAY,
so_tvers FOR bapicostingversion-low NO-DISPLAY,
so_date FOR bapivalidi-low NO-DISPLAY,
so_stat FOR bapicstgst-low NO-DISPLAY.
* No Display
PARAMETERS: coststat LIKE bapicostes-cosestimat DEFAULT 3
MODIF ID hid NO-DISPLAY.
PARAMETERS: view LIKE bapicostes-view
DEFAULT '01' NO-DISPLAY.
PARAMETERS: p_curr LIKE bapicostes-currency DEFAULT '01'
MODIF ID hid NO-DISPLAY.
* Para Birimi 01 için TRY, 02 için EUR değerini vermektedir.
SELECTION-SCREEN: END OF BLOCK b2.
* ----------------------------- Event Bilgileri --------------------- *
*&---------------------------------------------------------------------*
*& Form initial_condition
*&---------------------------------------------------------------------*
* Initial
*----------------------------------------------------------------------*
FORM initial_condition .
REFRESH: i_main.
CLEAR : i_main.
* Mara Bilgisi Ana Kaydı
SELECT * APPENDING CORRESPONDING FIELDS OF TABLE i_main
FROM mara
WHERE marka EQ so_marka-low
AND yil EQ so_yil-low
AND sezon EQ so_sezon-low
AND grup IN so_grup
AND matnr IN so_matnr .
break tlise.
ENDFORM. " initial_condition
*&---------------------------------------------------------------------*
*& Form fill_i_main
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM fill_i_main .
CLEAR : i_main.
break tlise.
LOOP AT i_main.
SELECT SINGLE * FROM makt WHERE matnr EQ i_main-matnr
AND spras EQ sy-langu .
IF sy-subrc EQ 0.
i_main-maktx = makt-maktx.
* Kar Marjı
SELECT SINGLE * FROM a501 WHERE matnr EQ i_main-matnr
AND kschl EQ 'BKM'
AND vkorg EQ '2000'
AND datbi EQ '99991231'.
IF sy-subrc EQ 0.
SELECT SINGLE * FROM konp WHERE knumh EQ a501-knumh.
IF sy-subrc EQ 0.
i_main-kbetr = -1 * ( konp-kbetr ) / 10.
ENDIF.
ENDIF.
* PSF
SELECT SINGLE * FROM a501 WHERE matnr EQ i_main-matnr
AND kschl EQ 'PSF1'
AND vkorg EQ '2000'
AND datbi EQ '99991231'.
IF sy-subrc EQ 0.
SELECT SINGLE * FROM konp WHERE knumh EQ a501-knumh.
IF sy-subrc EQ 0.
i_main-psf_kbetr = konp-kbetr.
ENDIF.
ENDIF.
* Mara-Anagrup = 1 => EUR ; Mara-Anagrup = 2 veya 3 => USD
CASE i_main-anagrup.
WHEN '1'.
i_main-lparabir = 'EUR'.
WHEN '2'.
i_main-lparabir = 'USD'.
WHEN '3'.
i_main-lparabir = 'USD'.
ENDCASE.
* Maliyet Bilgisinin Bulunması (BAPI den)
PERFORM find_cost_estimate_values.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
IF ok_code EQ 'BACK' OR ok_code EQ '%EX' OR ok_code EQ 'RW'.
LEAVE PROGRAM.
ENDIF.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Form write_i_main_for_alv
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM write_i_main_for_alv .
*-----------------------------------------------------------------------
* Instead of statement 'INCLUDE <icon>.', please use
* statement 'TYPE-POOLS: icon.' directly.
*-----------------------------------------------------------------------
TYPE-POOLS: icon.
DATA: gt_fieldcat TYPE slis_fieldcat_alv OCCURS 1 WITH HEADER LINE.
DATA: col_pos LIKE gt_fieldcat-col_pos.
DATA: lt_events TYPE slis_t_event.
DATA: ls_layout TYPE slis_layout_alv.
DATA: lt_event_exit TYPE slis_t_event_exit.
DATA: ls_event_exit TYPE slis_event_exit.
DATA: sortitab TYPE slis_t_sortinfo_alv WITH HEADER LINE.
DATA: handle_style TYPE lvc_t_styl.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = 'ZTMPTLSD_B_LISTE_PSF_UPDATE02'
i_internal_tabname = 'I_MAIN'
i_inclname = 'ZTMPTLSD_B_LISTE_PSF_UPDATE02'
CHANGING
ct_fieldcat = gt_fieldcat[].
*
LOOP AT gt_fieldcat.
CASE gt_fieldcat-fieldname.
*&---------------------------------------------------------------------*
*& Form eventtab_build
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_TB_EVENTS text
*----------------------------------------------------------------------*
FORM eventtab_build CHANGING lt_events TYPE slis_t_event.
CONSTANTS:
gc_formname_top_of_page TYPE slis_formname VALUE 'ALV_TOP_OF_PAGE',
gc_formname_pf_status_set TYPE slis_formname VALUE 'PF_STATUS_SET',
gc_formname_user_command TYPE slis_formname VALUE 'USER_COMMAND'.
DATA: ls_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = lt_events.
* Define TOP_OF_PAGE
READ TABLE lt_events WITH KEY name = slis_ev_top_of_page
INTO ls_event.
IF sy-subrc = 0.
MOVE gc_formname_top_of_page TO ls_event-form.
APPEND ls_event TO lt_events.
ENDIF.
* Define PF_STATUS_SET event
READ TABLE lt_events WITH KEY name = slis_ev_pf_status_set
INTO ls_event.
IF sy-subrc = 0.
MOVE gc_formname_pf_status_set TO ls_event-form.
APPEND ls_event TO lt_events.
ENDIF.
* Define USER_COMMAND event
READ TABLE lt_events WITH KEY name = slis_ev_user_command
INTO ls_event.
IF sy-subrc = 0.
MOVE gc_formname_user_command TO ls_event-form.
APPEND ls_event TO lt_events.
ENDIF.
ENDFORM. " eventtab_build
*&---------------------------------------------------------------------*
*& Form pf_status_set
*&---------------------------------------------------------------------*
FORM pf_status_set USING rt_extab TYPE slis_t_extab .
SET PF-STATUS 'GUI100'.
ENDFORM. "set_status
*&---------------------------------------------------------------------*
*& Form user_command
*&---------------------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
break tlise.
CASE r_ucomm.
WHEN 'AKTAR'.
PERFORM update_liste_psf.
* WHEN OTHERS.
* SET SCREEN 0.
ENDCASE.
* rs_selfield-refresh = 'X'.
ENDFORM. "user_command
*&---------------------------------------------------------------------*
*& Form alv_top_of_page
*&---------------------------------------------------------------------*
FORM alv_top_of_page.
DATA : vi_str(200).
CLEAR: st_header_line.
FREE : tb_header.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = 'LOGO1'
it_list_commentary = tb_header.
ENDFORM. " aalv_top_of_page.
*&---------------------------------------------------------------------*
*& Form find_cost_estimate_values
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM find_cost_estimate_values .
* BAPI' nin okuyabilmesi için internal table yapıldı.
REFRESH stabmara.
CLEAR stabmara.
MOVE : 'I' TO stabmara-sign,
'EQ' TO stabmara-option,
i_main-matnr TO stabmara-low.
APPEND stabmara.
* Sort sırası çok önemli.. KPM4 doluysa Maliyet olarak BBP4' ü alacak.
* Eğer KPM4 ve BBP4 yoksa KPM3 ve BBP3' e bakacak. Bu sıra KPM2 ve BBP2;
* KPM1 ve BBP1 şeklinde devam edecek. KPM1 yoksa BBP1 maliyet olarak
* alınacak.
* SORT costestimate_list BY cstg_num ASCENDING cstg_type DESCENDING.
SORT costestimate_list BY cstg_num ASCENDING cstg_type ASCENDING.
break tlise.
IF returndetail-type = 'E' OR returndetail-type = 'A'.
REFRESH cost_components.
CLEAR cost_estimate_header.
ENDIF.
CASE cost_estimate_header-cstg_vrnt.
WHEN 'BBP4'.
i_main-maliyet = cost_estimate_header-total_amt.
i_main-mparabir = 'TRY' .
EXIT.
WHEN 'BBP3'.
i_main-maliyet = cost_estimate_header-total_amt.
i_main-mparabir = 'TRY' .
EXIT.
WHEN 'BBP2'.
i_main-maliyet = cost_estimate_header-total_amt.
i_main-mparabir = 'TRY' .
EXIT.
WHEN 'BBP1'.
i_main-maliyet = cost_estimate_header-total_amt.
i_main-mparabir = 'TRY' .
EXIT.
ENDCASE.
ENDLOOP.
ENDFORM. " find_cost_estimate_values
*&---------------------------------------------------------------------*
*& Form update_liste_psf
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM update_liste_psf.
DATA: l_headdata LIKE /afs/bapimathead OCCURS 0 WITH HEADER LINE,
va_return LIKE bapiret2,
tb_returnmessages LIKE bapi_matreturn2 OCCURS 0 WITH header line.
DATA: i_bapiparex LIKE bapiparex OCCURS 0.
* w_bapiparex LIKE bapiparex .
* DATA: w_bapi_te_mara LIKE bapi_te_mara ,
* w_bapi_te_marax LIKE bapi_te_marax .
LOOP AT i_main.
* BAPI değerlerinin doldurulması
PERFORM fill_data.
ENDFORM. " update_liste_psf
*&---------------------------------------------------------------------*
*& Form fill_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM fill_data .
* va_headdata LIKE /AFS/BAPIMATHEAD,
* va_valuationdata LIKE bapi_mbew,
* va_valuationdatax LIKE bapi_mbewx,
* Exporting ve Tables (l_poitem ve l_poitemx) Bilgileri Dolduruluyor
DATA: l_headdata LIKE /afs/bapimathead .
* l_poheaderx LIKE bapimepoheaderx OCCURS 0 WITH HEADER LINE.
* DATA: l_poitem LIKE bapimepoitem OCCURS 0 WITH HEADER LINE,
* l_poitemx LIKE bapimepoitemx OCCURS 0 WITH HEADER LINE.
DATA: gt_bapiret2 LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
DATA: i_bapiparex LIKE bapiparex OCCURS 0.
data: w_bapiparex LIKE bapiparex .
DATA: w_bapi_te_mara LIKE bapi_te_mara ,
w_bapi_te_marax LIKE bapi_te_marax .
* Mara-zzlstpsf ve Mara-lstpbr bilgilerinin update edilmesi istendi.
* Bu bilgiler Ek Geliştirmeler içinde olduğundan Tables -> EXTENSIONIN
* bilgisinin kullanılması gerekmektedir.
* Tables -> EXTENSIONIN -> Long Text kısmına bakınca 2 adet BAPI
* structure table olduğunu görürüz. Bunlar ;
* BAPI_TE_MARA ve BAPI_TE_MARAX dir.
w_bapi_te_mara-material = i_main-matnr.
* w_bapi_te_mepoitem-zzwkurs = i_ekpo-zzwkurs.
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.