‎2011 Feb 18 12:41 PM
Dear Experts,
I have a requirement for Batch Internal Number for material type(HALB, FERT, ROH). My Consultants has created a 3 Intervals in SPRO. Client need Alpha numeric batch number, so i have used the exit EXIT_SAPLV01Z_002 and written the code for Alpha numeric number for batch and they need this number in Goods Receipt and movement type is '101'
But the problem is in NRIV table we have 06, 07, 08 are the intervals and i want to code 06 for HALB, 07 for FERT, 08 for ROH. When I was worked for HALB it is working fine, but i am not getting for FERT and ROH. How can I resolve this?
Thanks and Regards,
Muralikrishna
‎2011 Feb 18 2:22 PM
‎2011 Feb 21 5:02 AM
Hi Clemens,
My Apologies for not being replied to you due to I was in off(Saturday and Sunday). Here I am pasting my code. When I was trying for HALB then it is coming, Consultants need batch number for FERT and ROH. I have written this code in EXIT_SAPLV01Z_002
SELECT SINGLE VERID INTO LV_VERID
FROM AFPO WHERE AUFNR EQ X_BNCOM-aufnr.
select * from nriv into table xnriv where object eq 'BATCH_CLT'.
SELECT SINGLE MTART FROM MARA INTO LV_MTART WHERE MATNR EQ X_BNCOM-MATNR.
loop at xnriv.
clear : lv_batch,
lv_from.
if xnriv-nrrangenr eq '06'.
if xnriv-nrlevel is initial.
if sy-subrc eq 0.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = xnriv-fromnumber
IMPORTING
OUTPUT = xnriv-fromnumber
.
endif.
move xnriv-fromnumber to lv_from.
* lv_from = lv_from + 1.
concatenate lv_verid lv_from into lv_batch.
endif.
elseif xnriv-nrlevel is not initial.
if sy-subrc eq 0.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = xnriv-nrlevel
IMPORTING
OUTPUT = xnriv-nrlevel
.
endif.
move xnriv-nrlevel to lv_from.
* lv_from = lv_from + 1.
concatenate lv_verid lv_from into lv_batch.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
NR_RANGE_NR = '04'
OBJECT = 'BATCH_CLT'
* QUANTITY = '1'
* SUBOBJECT = ' '
* TOYEAR = '0000'
* IGNORE_BUFFER = ' '
IMPORTING
NUMBER = LV_FROM
* QUANTITY =
* RETURNCODE =
EXCEPTIONS
INTERVAL_NOT_FOUND = 1
NUMBER_RANGE_NOT_INTERN = 2
OBJECT_NOT_FOUND = 3
QUANTITY_IS_0 = 4
QUANTITY_IS_NOT_1 = 5
INTERVAL_OVERFLOW = 6
BUFFER_OVERFLOW = 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.
ENDIF.
endloop.
IF LV_VERID = 'K1' AND LV_BWART = '101' AND LV_MTART = 'HALB'.
new_charg = lv_batch.
elseif lv_verid = 'K2' and lv_bwart = '101' AND LV_MTART = 'HALB'. " AND LV_BWART1 = '531'.
new_charg = lv_batch.
ENDIF.
loop at xnriv.
clear : lv_batch,
lv_from.
if xnriv-nrrangenr eq '07'.
if xnriv-nrlevel is initial.
if sy-subrc eq 0.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = xnriv-fromnumber
IMPORTING
OUTPUT = xnriv-fromnumber
.
endif.
move xnriv-fromnumber to lv_from.
* lv_from = lv_from + 1.
concatenate lv_verid lv_from into lv_batch.
endif.
elseif xnriv-nrlevel is not initial.
if sy-subrc eq 0.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = xnriv-nrlevel
IMPORTING
OUTPUT = xnriv-nrlevel
.
endif.
move xnriv-nrlevel to lv_from.
* lv_from = lv_from + 1.
concatenate lv_verid lv_from into lv_batch.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
NR_RANGE_NR = '05'
OBJECT = 'BATCH_CLT'
* QUANTITY = '1'
* SUBOBJECT = ' '
* TOYEAR = '0000'
* IGNORE_BUFFER = ' '
IMPORTING
NUMBER = LV_FROM
* QUANTITY =
* RETURNCODE =
EXCEPTIONS
INTERVAL_NOT_FOUND = 1
NUMBER_RANGE_NOT_INTERN = 2
OBJECT_NOT_FOUND = 3
QUANTITY_IS_0 = 4
QUANTITY_IS_NOT_1 = 5
INTERVAL_OVERFLOW = 6
BUFFER_OVERFLOW = 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.
ENDIF.
endloop.
IF LV_VERID = 'K1' AND LV_BWART = '101' AND LV_MTART = 'FERT'.
new_charg = lv_batch.
elseif lv_verid = 'K2' and lv_bwart = '101' AND LV_MTART = 'FERT'. " AND LV_BWART1 = '531'.
new_charg = lv_batch.
ENDIF.
loop at xnriv.
clear : lv_batch,
lv_from.
if xnriv-nrrangenr eq '06'.
if xnriv-nrlevel is initial.
if sy-subrc eq 0.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = xnriv-fromnumber
IMPORTING
OUTPUT = xnriv-fromnumber
.
endif.
move xnriv-fromnumber to lv_from.
* lv_from = lv_from + 1.
* concatenate lv_verid lv_from into lv_batch.
endif.
elseif xnriv-nrlevel is not initial.
if sy-subrc eq 0.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = xnriv-nrlevel
IMPORTING
OUTPUT = xnriv-nrlevel
.
endif.
move xnriv-nrlevel to lv_from.
* lv_from = lv_from + 1.
* concatenate lv_verid lv_from into lv_batch.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
NR_RANGE_NR = '05'
OBJECT = 'BATCH_CLT'
* QUANTITY = '1'
* SUBOBJECT = ' '
* TOYEAR = '0000'
* IGNORE_BUFFER = ' '
IMPORTING
NUMBER = LV_FROM
* QUANTITY =
* RETURNCODE =
EXCEPTIONS
INTERVAL_NOT_FOUND = 1
NUMBER_RANGE_NOT_INTERN = 2
OBJECT_NOT_FOUND = 3
QUANTITY_IS_0 = 4
QUANTITY_IS_NOT_1 = 5
INTERVAL_OVERFLOW = 6
BUFFER_OVERFLOW = 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.
ENDIF.
endloop.
IF LV_VERID = 'K1' AND LV_BWART = '101' AND LV_MTART = 'ROH'.
new_charg = lv_from.
elseif lv_verid = 'K2' and lv_bwart = '101' AND LV_MTART = 'ROH'. " AND LV_BWART1 = '531'.
new_charg = lv_from.
ENDIF.
‎2011 Feb 19 7:12 AM
Hello again,
Implement the exit EXIT_SAPLV01Z_001 (SAPLV01Z).
Check the material type X_BNCOM-MTART and assign the relevent number range in NR_RANGE_NR.
Number ranges can be created in SNRO, NR object is BATCH_CLT.
‎2011 Feb 21 5:06 AM
Hi Asik,
My Apologies for not being replied your post due to i was in off. I tried in EXIT_SAPLV01Z_001 but i didnt got the result thats why i implemented in EXIT_SAPLV01Z_002
‎2011 Feb 21 9:05 AM
Hi muraliabap,
Thank you.
Please use the preview button to make sure the formatting is preserved. If not, reduce the size of posted code - there is a limit.
This way I just can not read the code.
BTW: Do you know the exit is processed? Online a breakpoint will do, in update or background task you have a couple of options to check: Use of ABAP Checkgroups with logpoint is my favorite, endless loop to be ended in debugger is an other way.
Regards,
Clemens
‎2011 Feb 21 9:21 AM
Hi Clemens,
Sorry for that.
SELECT SINGLE VERID INTO LV_VERID FROM AFPO WHERE AUFNR EQ X_BNCOM-aufnr.
select * from nriv into table xnriv where object eq 'BATCH_CLT'.
SELECT SINGLE MTART FROM MARA INTO LV_MTART WHERE MATNR EQ X_BNCOM-MATNR.
loop at xnriv.
clear : lv_batch, lv_from.
if xnriv-nrrangenr eq '06'.
if xnriv-nrlevel is initial.
if sy-subrc eq 0.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = xnriv-fromnumber
IMPORTING
OUTPUT = xnriv-fromnumber .
endif.
move xnriv-fromnumber to lv_from.
concatenate lv_verid lv_from into lv_batch.
endif.
elseif xnriv-nrlevel is not initial.
if sy-subrc eq 0.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = xnriv-nrlevel
IMPORTING
OUTPUT = xnriv-nrlevel .
endif.
move xnriv-nrlevel to lv_from.
concatenate lv_verid lv_from into lv_batch.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
NR_RANGE_NR = '06'
OBJECT = 'BATCH_CLT'
IMPORTING
NUMBER = LV_FROM
EXCEPTIONS
INTERVAL_NOT_FOUND = 1
NUMBER_RANGE_NOT_INTERN = 2
OBJECT_NOT_FOUND = 3
QUANTITY_IS_0 = 4
QUANTITY_IS_NOT_1 = 5
INTERVAL_OVERFLOW = 6
BUFFER_OVERFLOW = 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.
ENDIF.
endloop.
IF LV_VERID = 'K1' AND LV_BWART = '101' AND LV_MTART = 'HALB'.
new_charg = lv_batch.
elseif lv_verid = 'K2' and lv_bwart = '101' AND LV_MTART = 'HALB'.
new_charg = lv_batch.
ENDIF.
like this i have written the code for other material types. When I am doing the Goods Receipts the exit is calling
Edited by: muraliabap on Feb 21, 2011 10:25 AM
‎2011 Feb 22 5:29 AM
Dear Experts,
Any suggestion for my post
Thanks and Regards,
Muraikrishna
‎2011 Feb 22 7:16 AM
Hi Murali,
The code you posted is only for HALB materials, I can't see any condition for other 2 (FERT,ROH). Nesting of the conditions in your code is incorrect. Use Pretty Printer option and do proper nesting.
You are going complex which can be easily achieved by the exit which I mentioned in the previous post. Check this link for [SAP Help|http://help.sap.com/saphelp_40b/helpdata/pt/dc/1d4b6e5733d1118b3f0060b03ca329/content.htm]. Read the FM documentation for more detail.
Assign the Number Range Interval in EXIT_SAPLV01Z_001 and change it as Alphanumeric (Prefixing K1,K2,..) in EXIT_SAPLV01Z_002
‎2011 Feb 22 11:44 AM
Dear Asik,
I did what you said in previous post. Here the number is not incrementing, so can I use the FM called NUMBER_GET_NEXT ?
Thanks n Regards,
Muralikrishna
‎2011 Feb 25 5:04 AM
Dear Asik,
I am not incrementing the number in Item level when Goods Receipt, can you please suggest me?
Thanks n Regards,
Muralikrishna