2014 Apr 02 3:29 PM
Hello Experts,
I am creating a material through calling MM01 in a dialog program.
After the transaction completed, the control returns to my program, but i cannot find my material created in MARA, even though it gets created.
Even after writing several seconds of WAIT, the select returns subrc as '4'.
CALL TRANSACTION 'MM01'.
COMMIT WORK AND WAIT.
CALL FUNCTION 'DB_COMMIT'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
WAIT UP TO 4 SECONDS.
SELECT SINGLE matnr FROM mara
INTO v_matnr1
WHERE matnr = v_matnr.
A loop which keeps on checking in MARA (using select) can be performed, but if the user cancels the transaction purposely and does not want to create the material, then the user will have to wait un-neccessarily in the loop.
Let me know what else can be done?
Thanks ,
Rajat.
2014 Apr 03 10:15 AM
Well the line s after CALL TRANSACTION are not useful, transaction has already triggered its own commit without wait. so if you did not execute some update OPEN-SQL statements, remove :
COMMIT WORK AND WAIT.
CALL FUNCTION 'DB_COMMIT'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
Before trying to select the material record, first try to lock the record (ENQUEUE_EMMARAE with wait in a loop) if user has saved a material it will be kept locked by the update task until executed. then execute a single selection from MARA bypassing buffer, if not found a single WAIT 1 second would be sufficient (and often not necessary) to wait for DB server.
Also you could save another value in memory to detect actual creation of material (and actual number) with some BAdIs or a BTE like 00001250, if not found in memory, don't execute the wait.
FUNCTION z_interface_00001250.
*"--------------------------------------------------------------------
*"*"Interface locale :
*" IMPORTING
*" VALUE(I_MARA_NEW) LIKE MARA STRUCTURE MARA OPTIONAL
*" VALUE(I_MARA_OLD) LIKE MARA STRUCTURE MARA OPTIONAL
* etc.
*"--------------------------------------------------------------------
EXPORT i_mara_new-matnr TO MEMORY ID 'ZMATNR'.
ENDFUNCTION.
Regards,
Raymond
Hello Experts,
I am creating a material through calling MM01 in a dialog program.
After the transaction completed, the control returns to my program, but i cannot find my material created in MARA, even though it gets created.
Even after writing several seconds of WAIT, the select returns subrc as '4'.
CALL TRANSACTION 'MM01'.
COMMIT WORK AND WAIT.
CALL FUNCTION 'DB_COMMIT'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
WAIT UP TO 4 SECONDS.
SELECT SINGLE matnr FROM mara
INTO v_matnr1
WHERE matnr = v_matnr.
A loop which keeps on checking in MARA (using select) can be performed, but if the user cancels the transaction purposely and does not want to create the material, then the user will have to wait un-neccessarily in the loop.
Let me know what else can be done?
Thanks ,
Rajat.
2014 Apr 02 3:48 PM
How can your program work at all? Where is v_matnr getting set?
2014 Apr 02 3:55 PM
Hello Matthew,
I forgot to mention that i just pasted a part of my code, not the whole.
So v_matnr is set, it is just not here.
Thanks,
Rajat
2014 Apr 02 4:01 PM
well you may need to run the v_matnr through the conversion exit...as well depending on where that number is sourced - it may not have leading zeros or something similar in the select - but MM01 is formatting the number in internal format for you when saving
MATNR conv exits are:
MG_MATN1_RANGE MATN1 Conversion with Ranges
CONVERSION_EXIT_MATN1_RANGE_I Conversion Exit MATN1, External Range -> Internal Range
CONVERSION_EXIT_MATN1_RANGE_O Conversion Exit MATN1, Internal Range -> External Range
OMCV
CONVERSION_EXIT_MATN1_INPUT
CONVERSION_EXIT_MATN1_OUTPUT
use the right one
2014 Apr 02 3:57 PM
Matthew is right Rajat - your Material number is not set in v_matnr.
Firstly, you dont need a commit - MM01 will commit the update for you.
Fortunately, material number has a PID.
Use that after MM01
get parameter id 'MAT' field v_matnr.
Should set it ok....I reckon...
sorry, didn't try it myself in test, but am confident it will work.
2014 Apr 02 3:57 PM
Yes Matthew have a point.
where filling v_matnr.(You can use import the MATNR from MAT parameter fetch the MATNR and query MARA table)
2014 Apr 03 8:30 AM
Hello All,
Thanks for the comments. But all of this I have already done and it's not working. I will paste the some more extended code (this is not the full code):
Also the below code is working when I place a break-point inside the code and then sy-subrc after select statement has value '0'.
I cannot use the parameter-id to check whether it is set after MM01, because i am already setting it before calling the transaction.
SET PARAMETER ID 'MAT' FIELD mara-matnr
CALL TRANSACTION 'MM01'.
COMMIT WORK AND WAIT.
CALL FUNCTION 'DB_COMMIT'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
WAIT UP TO 4 SECONDS.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = mara-matnr
IMPORTING
output = v_matnr.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = v_matnr
IMPORTING
output = v_matnr.
SELECT SINGLE matnr FROM mara
INTO v_matnr1
WHERE matnr = v_matnr.
IF sy-subrc EQ 0.
.
The issue is, that even after commit work and wait, and other commits and waits, still the DB takes time to reflect value in MARA.
Is there any interim table which tells me whether the update has been carried out successfully or not ?
Thanks,
Rajat.
2014 Apr 03 8:51 AM
Is MARA buffered? Probably not. But if it is, try BYPASSING BUFFER. But no - there is no interim table.
Instead of waiting 4 seconds, you should first check if the data is there. If not, then loop a few times, wiating each loop, until the data is there, or you give up. That way, if the data is there quickly, you don't have any delay.
You do not need your DB_COMMIT and BAPI_TRANSACTION_COMMIT, unless you've got some other data that needs to be committed. It will have no effect on MM01.
2014 Apr 03 9:29 AM
Hello Matthew,
Thanks, but.
You do not need your DB_COMMIT and BAPI_TRANSACTION_COMMIT, unless you've got some other data that needs to be committed. It will have no effect on MM01.
- Agreed. I just put it there for some additional checks.
Instead of waiting 4 seconds, you should first check if the data is there. If not, then loop a few times, waiting each loop, until the data is there, or you give up. That way, if the data is there quickly, you don't have any delay.- That would work, but in the case , when the user does a 'CANCEL' or 'EXIT' from MM01, he has to wait, while the loop completes.
Regards,
Rajat.
2014 Apr 03 9:33 AM
Hi Rajat,
How did you get the MATNR before the call transaction MM01?
2014 Apr 03 9:04 AM
Have you done a manual check ? Please try follwoing:
1.) After BAPI_TRANSACTION_COMMIT put DEQUE_ALL.
2.) Put a break point on SELECT SINGLE matnr FROM mara. When program execution will stop there, manully check using T-Code MM03 , whether material created , if created then check entry in MARA table using t-code SE16 or SE11.
Anyways Material master upate is huge thing and it tooks time to update completly.
BR,
Prakash
2014 Apr 03 9:26 AM
Hi,
are you able to see the material created in MM03 or mara table? if yes, then
after commit statement,
get parameter id 'MAT' field v_matnr.
This should do.
Regards-
Makarand
2014 Apr 03 9:32 AM
Hello Makarand,
Thanks for the suggestion.
Yes i can see the material in MM03, but as I am setting the parameter id 'MAT' myself before calling MM01, it would always return value in it.
Hence, I cannot use that.
Regards,
Rajat.
2014 Apr 03 9:40 AM
ok.. that means it is external no range.
Strange issue. Just try to condence v_matnr before the select statement.
Regards-
Makarand
2014 Apr 03 9:42 AM
Rajat
As already pointed out by Matthew you can put a maximum time limit lets say you try for 30 seconds in a loop if you get it you exit else you exit after 30 seconds(meaning either user cancelled it or your system is too slow:))
Nabheet
2014 Apr 03 9:53 AM
report ztest.
tables mara.
data ls_mara type mara.
parameters p_matnr type matnr.
start-of-selection.
set parameter id 'MAT' field p_matnr.
break-point.
call transaction 'MM01'.
select single * from mara into ls_mara
where matnr = p_matnr.
if sy-subrc is initial.
break-point.
endif.
here pid assigned and sy-subrc is 0
then the tcode call to mm01, immediately after - but the matnr field on screen is NOT set.
Can you show me your screenshots when you execute on your system
Cheers
2014 Apr 03 10:03 AM
further, if i change the tcode to MM03 and use material 123, now see what happens
as you can see my material of 123 now gets set correctly - and also SAP has put leading zeros in.
so MM01 and MM03 are treating the PID differently - I have seen some tcodes CLEAR PIDs in create mode....in the past
do a bit more debug...
Cheers
2014 Apr 03 9:46 AM
Hi Rajat,
After calling transaction MM01
just code as below.
Get parameter id 'MAT' field V_MATNR
and convert this material no as input using conversion.
Then do select query as it is.
Hope this will definitely work.
Thanks and Regards
Srimanta
2014 Apr 03 10:08 AM
Thinking outside the box for a moment, if you're needing to wrap MM01 in other functionality, perhaps this can be best achieved via a workflow.
2014 Apr 03 10:15 AM
Well the line s after CALL TRANSACTION are not useful, transaction has already triggered its own commit without wait. so if you did not execute some update OPEN-SQL statements, remove :
COMMIT WORK AND WAIT.
CALL FUNCTION 'DB_COMMIT'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
Before trying to select the material record, first try to lock the record (ENQUEUE_EMMARAE with wait in a loop) if user has saved a material it will be kept locked by the update task until executed. then execute a single selection from MARA bypassing buffer, if not found a single WAIT 1 second would be sufficient (and often not necessary) to wait for DB server.
Also you could save another value in memory to detect actual creation of material (and actual number) with some BAdIs or a BTE like 00001250, if not found in memory, don't execute the wait.
FUNCTION z_interface_00001250.
*"--------------------------------------------------------------------
*"*"Interface locale :
*" IMPORTING
*" VALUE(I_MARA_NEW) LIKE MARA STRUCTURE MARA OPTIONAL
*" VALUE(I_MARA_OLD) LIKE MARA STRUCTURE MARA OPTIONAL
* etc.
*"--------------------------------------------------------------------
EXPORT i_mara_new-matnr TO MEMORY ID 'ZMATNR'.
ENDFUNCTION.
Regards,
Raymond
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |