11-15-2007 5:42 PM
Hi,
I have a program that will display a material number, plant and rounding value. There is a button change material number in the upper part..
so when i click on the button change material number it will go to the transaction MM02..
when the user will change the bstrf then and after saving the changes the output should refresh meaning the new value of the bstrf will be the new one...
could anybody can help me how to do this?
thank you...
regards,
mae
11-15-2007 6:05 PM
Try this code ::::
parameters: p_test type i DEFAULT 1.
at selection-screen output.
AT SELECTION-SCREEN.
CALL FUNCTION 'RFC_PING_AND_WAIT'
STARTING NEW TASK 'WAITING'
PERFORMING RETURN_FROM_WAIT ON END OF TASK
EXPORTING SECONDS = 5.
IF SY-UCOMM EQ 'REFRESH'.
ADD 10 TO P_TEST.
ENDIF.
FORM RETURN_FROM_WAIT USING TASKNAME.
set user-command 'REFRESH'.
ENDFORM.
CHEERS!!
<a href="http://www.abapforum.com/forum/viewtopic.php?t=2850&highlight=clguitimer">http://www.abapforum.com/forum/viewtopic.php?t=2850&highlight=clguitimer</a><a href="http://www.abapforum.com/forum/viewtopic.php?t=2850&highlight=clguitimer">http://www.abapforum.com/forum/viewtopic.php?t=2850&highlight=clguitimer</a>
11-15-2007 5:50 PM
IN your AVL's USER_COMMAND, when your control comes back from the MM02, retrive the data again from the database and refresh the same internal table with this latest values.
You need to refresh the alv by
RS_SELFIELD-REFRESH = 'X'.
Regards,
Naimesh Patel
11-15-2007 5:53 PM
11-15-2007 6:01 PM
Hi
Use the BAPI
BAPI_MATERIAL_SAVEREPLICA and do the changes
see the sample code
&----
*& Report YTEST_ANJI_CHECK_BAPI
&----
REPORT ytest_anji_check_bapi.
TABLES : mara.
PARAMETERS : p_matnr LIKE mara-matnr, " Material to be created.
p_werks LIKE marc-werks. " Plant
DATA : wa_headdata LIKE bapie1matheader,
wa_clntdata LIKE bapie1mara,
wa_clntdatax LIKE bapie1marax,
wa_plntdata LIKE bapie1marc,
wa_plntdatax LIKE bapie1marcx,
wa_slsdata LIKE bapie1mvke,
wa_slsdatax LIKE bapie1mvkex,
wa_valdata LIKE bapie1mbew,
wa_valdatax LIKE bapie1mbewx,
wa_ret LIKE bapie1ret2,
it_headdata LIKE bapie1matheader OCCURS 0,
it_clntdata LIKE bapie1mara OCCURS 0,
it_clntdatax LIKE bapie1marax OCCURS 0,
it_plntdata LIKE bapie1marc OCCURS 0,
it_plntdatax LIKE bapie1marcx OCCURS 0,
it_slsdata LIKE bapie1mvke OCCURS 0,
it_slsdatax LIKE bapie1mvkex OCCURS 0,
it_valdata LIKE bapie1mbew OCCURS 0,
it_valdatax LIKE bapie1mbewx OCCURS 0,
it_ret LIKE bapie1ret2 OCCURS 0,
it_makt LIKE bapie1makt OCCURS 1 WITH HEADER LINE.
START-OF-SELECTION.
wa_headdata-function = 'UPD'.
wa_headdata-material = p_matnr.
wa_headdata-ind_sector = 'M'.
wa_headdata-matl_type = 'FERT'.
wa_headdata-basic_view = 'X'.
wa_headdata-mrp_view = 'X'.
wa_headdata-sales_view = 'X'.
wa_headdata-purchase_view = 'X'.
wa_headdata-account_view = 'X'.
wa_headdata-storage_view = 'X'.
APPEND wa_headdata
TO it_headdata.
CLEAR wa_headdata.
Basic View
wa_clntdata-function = 'UPD'.
wa_clntdata-material = p_matnr.
wa_clntdata-matl_group = '4MX000'.
wa_clntdata-base_uom = 'PCE'.
wa_clntdata-base_uom_iso = 'PCE'.
wa_clntdata-prod_hier = '90941012S751615'.
wa_clntdata-dsn_office = 'A60'.
wa_clntdata-mat_grp_sm = '0001'.
wa_clntdata-trans_grp = 'ZS01'.
APPEND wa_clntdata
TO it_clntdata.
wa_clntdatax-function = 'UPD'.
wa_clntdatax-material = p_matnr.
wa_clntdatax-matl_group = 'X'.
wa_clntdatax-base_uom = 'X'.
wa_clntdatax-base_uom_iso = 'X'.
wa_clntdatax-prod_hier = 'X'.
wa_clntdatax-dsn_office = 'X'.
wa_clntdatax-mat_grp_sm = 'X'.
wa_clntdatax-trans_grp = 'X'.
APPEND wa_clntdatax
TO it_clntdatax.
MRP & Plant Data View
wa_plntdata-function = 'UPD'.
wa_plntdata-material = p_matnr.
wa_plntdata-plant = p_werks.
wa_plntdata-abc_id = 'A'.
wa_plntdata-pur_group = '003'.
wa_plntdata-mrp_type = 'ND'.
wa_plntdata-mrp_ctrler = 'BT2'.
wa_plntdata-plnd_delry = '1'.
wa_plntdata-gr_pr_time = '1'.
wa_plntdata-period_ind = 'P'.
wa_plntdata-proc_type = 'F'.
wa_plntdata-spproctype = '20'.
wa_plntdata-eff_o_day = sy-datum + 365.
wa_plntdata-batch_mgmt = 'X'.
wa_plntdata-expimpgrp = '0'.
wa_plntdata-profit_ctr = 'S75'.
wa_plntdata-mrp_group = '0001'.
wa_plntdata-availcheck = '02'.
wa_plntdata-fy_variant = 'ZP'.
wa_plntdata-countryori = 'IN'.
wa_plntdata-loadinggrp = 'ZS01'.
wa_plntdata-comm_code = '9018130000'.
wa_plntdata-auto_p_ord = 'X'.
APPEND wa_plntdata
TO it_plntdata.
wa_plntdatax-function = 'UPD'.
wa_plntdatax-material = p_matnr.
wa_plntdatax-plant = p_werks.
wa_plntdatax-abc_id = 'X'.
wa_plntdatax-pur_group = 'X'.
wa_plntdatax-mrp_type = 'X'.
wa_plntdatax-mrp_ctrler = 'X'.
wa_plntdatax-plnd_delry = 'X'.
wa_plntdatax-gr_pr_time = 'X'.
wa_plntdatax-period_ind = 'X'.
wa_plntdatax-proc_type = 'X'.
wa_plntdatax-spproctype = 'X'.
wa_plntdatax-eff_o_day = 'X'.
wa_plntdatax-batch_mgmt = 'X'.
wa_plntdatax-expimpgrp = 'X'.
wa_plntdatax-profit_ctr = 'X'.
wa_plntdatax-mrp_group = 'X'.
wa_plntdatax-availcheck = 'X'.
wa_plntdatax-fy_variant = 'X'.
wa_plntdatax-sloc_exprc = 'X'.
wa_plntdatax-countryori = 'X'.
wa_plntdatax-loadinggrp = 'X'.
wa_plntdatax-comm_code = 'X'.
wa_plntdatax-auto_p_ord = 'X'.
APPEND wa_plntdatax
TO it_plntdatax.
Sales View
wa_slsdata-function = 'UPD'.
wa_slsdata-material = p_matnr.
wa_slsdata-sales_org = 'AB9S'.
wa_slsdata-distr_chan = 'NL'.
wa_slsdata-prod_hier = '90941012S751615'.
wa_slsdata-mat_pr_grp = 'Z6'.
wa_slsdata-prod_att_1 = 'X'.
wa_slsdata-prod_att_2 = 'X'.
wa_slsdata-prod_att_3 = 'X'.
wa_slsdata-item_cat = 'ZRET'.
wa_slsdata-acct_assgt = '11'.
wa_slsdata-matl_stats = '1'.
APPEND wa_slsdata
TO it_slsdata.
wa_slsdatax-function = 'UPD'.
wa_slsdatax-material = p_matnr.
wa_slsdatax-sales_org = 'IN9S'.
wa_slsdatax-distr_chan = 'IN'.
wa_slsdatax-prod_hier = 'X'.
wa_slsdatax-mat_pr_grp = 'X'.
wa_slsdatax-prod_att_1 = 'X'.
wa_slsdatax-prod_att_2 = 'X'.
wa_slsdatax-prod_att_3 = 'X'.
wa_slsdatax-item_cat = 'X'.
wa_slsdatax-acct_assgt = 'X'.
wa_slsdatax-matl_stats = 'X'.
APPEND wa_slsdatax
TO it_slsdatax.
Accounting Data View
wa_valdata-function = 'UPD'.
wa_valdata-material = p_matnr.
wa_valdata-val_area = 'IN9S'.
wa_valdata-val_type = space.
wa_valdata-price_ctrl = 'V'.
wa_valdata-moving_pr = 100.
wa_valdata-price_unit = 1.
wa_valdata-val_class = '7920'.
wa_valdata-val_cat = 'S'.
APPEND wa_valdata
TO it_valdata.
wa_valdatax-function = 'UPD'.
wa_valdatax-material = p_matnr.
wa_valdatax-val_area = 'IN9S'.
wa_valdatax-val_type = space.
wa_valdatax-price_ctrl = 'X'.
wa_valdatax-moving_pr = 'X'.
wa_valdatax-price_unit = 'X'.
wa_valdatax-val_class = 'X'.
wa_valdatax-val_cat = 'X'.
APPEND wa_valdatax
TO it_valdatax.
Material Description
it_makt-material = p_matnr.
it_makt-langu = 'E'.
it_makt-langu_iso = 'EN'.
it_makt-matl_desc = 'Material using BAPI SAVE REPLICA'.
APPEND it_makt.
CLEAR it_makt.
CALL FUNCTION 'BAPI_MATERIAL_SAVEREPLICA'
EXPORTING
noappllog = space
nochangedoc = space
testrun = space
inpfldcheck = space
TABLES
headdata = it_headdata
clientdata = it_clntdata
clientdatax = it_clntdatax
plantdata = it_plntdata
plantdatax = it_plntdatax
valuationdata = it_valdata
valuationdatax = it_valdatax
salesdata = it_slsdata
salesdatax = it_slsdatax
materialdescription = it_makt
returnmessages = it_ret.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
LOOP AT it_ret INTO wa_ret.
WRITE / wa_ret-message.
ENDLOOP.
Regards
Anji
11-15-2007 6:18 PM
Hi
do you have a simplier code for this?
because i am just new to SAP
thank you
regards,
mae
11-15-2007 6:05 PM
Try this code ::::
parameters: p_test type i DEFAULT 1.
at selection-screen output.
AT SELECTION-SCREEN.
CALL FUNCTION 'RFC_PING_AND_WAIT'
STARTING NEW TASK 'WAITING'
PERFORMING RETURN_FROM_WAIT ON END OF TASK
EXPORTING SECONDS = 5.
IF SY-UCOMM EQ 'REFRESH'.
ADD 10 TO P_TEST.
ENDIF.
FORM RETURN_FROM_WAIT USING TASKNAME.
set user-command 'REFRESH'.
ENDFORM.
CHEERS!!
<a href="http://www.abapforum.com/forum/viewtopic.php?t=2850&highlight=clguitimer">http://www.abapforum.com/forum/viewtopic.php?t=2850&highlight=clguitimer</a><a href="http://www.abapforum.com/forum/viewtopic.php?t=2850&highlight=clguitimer">http://www.abapforum.com/forum/viewtopic.php?t=2850&highlight=clguitimer</a>
11-15-2007 6:23 PM
hi,
it wont work..
do you have any other solution for this problem?
thank you
regards,
mae
11-15-2007 7:44 PM
Ok.. I have tried to make a sample code for this:
Put break points and debug the code.
REPORT ZTEST_NP.
DATA: BEGIN OF ITAB OCCURS 0,
MATNR LIKE MARA-MATNR,
MATKL LIKE MARA-MATKL,
END OF ITAB.
DATA: W_MATNR LIKE MARA-MATNR,
L_INDEX LIKE SY-INDEX.
START-OF-SELECTION.
SELECT MATNR MATKL
INTO TABLE ITAB
FROM MARA
UP TO 10 ROWS.
SET PF-STATUS 'ZTEST_NP'.
LOOP AT ITAB.
WRITE: / ITAB-MATNR,
ITAB-MATKL.
W_MATNR = ITAB-MATNR.
HIDE W_MATNR.
ENDLOOP.
AT LINE-SELECTION.
IF SY-UCOMM = 'PICK'.
SET PARAMETER ID 'MAT' FIELD W_MATNR.
CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.
READ TABLE ITAB WITH KEY MATNR = W_MATNR.
IF SY-SUBRC = 0.
L_INDEX = SY-TABIX.
SELECT SINGLE MATNR MATKL
INTO ITAB
FROM MARA
WHERE MATNR = W_MATNR.
MODIFY ITAB INDEX L_INDEX.
ENDIF.
SY-LSIND = 0.
LOOP AT ITAB.
WRITE: / ITAB-MATNR,
ITAB-MATKL.
W_MATNR = ITAB-MATNR.
HIDE W_MATNR.
ENDLOOP.
ENDIF.
Regards,
Naimesh Patel
11-15-2007 7:51 PM
hi,
thank you for that..
but i need to display an top of page..
how will i do that?
again thank you...
regards,
mae
11-15-2007 7:52 PM
Use Event TOP-OF-PAGE.
TOP-OF-PAGE.
PERFORM TOP_OF_PAGE.
Regards,
Naimesh Patel
11-15-2007 7:57 PM
what i was trying to say is that when the first time i display the data it has a top of page but when i already change something in the MMO2 like for example the BSTRF and save.
after saving the changes the output should display the updated data..so how can i call the top of page this time...
thank you
regards,
mae
11-15-2007 7:58 PM
Just call this PERFORM TOP_OF_PAGE before your write statement.
SY-LSIND = 0.
PERFORM TOP_OF_PAGE. "<<<
LOOP AT ITAB.
WRITE: / ITAB-MATNR,
ITAB-MATKL.
W_MATNR = ITAB-MATNR.
HIDE W_MATNR.
ENDLOOP.
Regards,
Naimesh Patel
11-15-2007 8:03 PM
hi,
you are so great...
another question..
how about when i already had an page 2..
how will it display the page 2?
thank you so much...
regards,
mae
11-15-2007 8:08 PM
There would be a limitation.. when you tries to print the report, your top of page data will not come..
I think we don't have much room here...
Regards,
Naimesh Patel
11-15-2007 8:12 PM
hi,
those it mean that it is not possible to display the top of page with the pages?
or
display the top of page in the updated output?
thank you..
regards,
mayang
11-15-2007 8:14 PM
In the updated output.. (after the AT LINE-Selection), Perform top_of_page will only execute once.. so, you will have it only on the first page.
But, if nobody is going to print this report, than you don't have to worry about this.
Regards,
Naimesh Patel
11-15-2007 8:29 PM
hi,
we need to display the top of page with pages..
and on the both output..
it is possible?
regards,
mae
11-15-2007 8:34 PM
Yes.. actually I forgot this feature ..
Just add this top-of-page DURING LINE-SELECTION in your program.
top-of-page.
perform top_of_page.
top-of-page DURING LINE-SELECTION .
perform top_of_page.
Regards,
Naimesh Patel
11-15-2007 8:40 PM