on 2012 Feb 01 9:35 AM
In include MV45AFZZ USEREXIT_SAVE_DOCUMENT_PREPARE I have added code to display information message if profit centre is initial/blank for any line item.
Suppose there are 3 line items for a sales order with line item 20 & 30 having profit centers as initial/blank. I get my information message displayed as Profit centre not maintained for line items: 20, 30. Then I press enter and it allows me to add profit centers for the missing line items.
I assign profit centre for line item 20 only and for line item 30 I want it to be blank. Then I save it.
Here comes my issue :
Again information message displays as u201C Profit centre not maintained for line item 30u201D. Unless I enter profit center value in line item 30 the message displays. If I enter some value and save it then document is saved.
I need the message to be displayed only once and user can enter missing profit centre for any line item & save it. Now its mandatory to enter profit center for all line items.
IF FLAG IS INITIAL.
LOOP AT xvbap.
IF xvbap-prctr IS INITIAL.
lv_posnr = xvbap-posnr.
CONDENSE lv_posnr.
CALL FUNCTION 'BKK_DELETE_LEADING_ZERO'
CHANGING
c_field = lv_posnr.
IF lv_text IS NOT INITIAL.
CONCATENATE lv_text lv_posnr into lv_text SEPARATED BY ','.
ELSE.
lv_text = lv_posnr.
ENDIF.
ENDIF.
CLEAR lv_posnr .
ENDLOOP.
IF lv_text IS NOT INITIAL.
fcode = 'ENT1'.
CONCATENATE zmsg_txt lv_text INTO zmsg.
message i000(ZZ) WITH zmsg.
FLAG = 1.
fcode = 'ENT1'.
LEAVE TO SCREEN 4001.
ENDIF.
ENDIF.
~Arya
Edited by: arya soumya on Feb 1, 2012 10:36 AM
Hello,
I would suggest to declare a static variable type c in include MV45ATZZ; and pass 'X' after calling FM 'BKK_DELETE_LEADING_ZERO'
.
Check the same variable's value before calling the FM..
..
Hope it will solve the problem but beware second time pop up will not come although user did not enter profit center.
.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Krishnendu,
LOOP AT xvbap.
IF xvbap-prctr IS INITIAL.
lv_posnr = xvbap-posnr.
CONDENSE lv_posnr.
if v_flag = 'X'. "is this what your are trying to convey : v_flag is declared static
CALL FUNCTION 'BKK_DELETE_LEADING_ZERO'
CHANGING
c_field = lv_posnr.
v_flag = 'X'. "changes here
IF lv_text IS NOT INITIAL.
CONCATENATE lv_text lv_posnr into lv_text SEPARATED BY ','.
ELSE.
lv_text = lv_posnr.
ENDIF.
ENDIF.
CLEAR lv_posnr .
ENDLOOP.
IF lv_text IS NOT INITIAL.
if fcode = 'ENT1'.
CONCATENATE zmsg_txt lv_text INTO zmsg.
message i000(ZZ) WITH zmsg.
fcode = 'ENT1'.
LEAVE TO SCREEN 4001.
ENDIF.
ENDIF.
Edited by: arya soumya on Feb 1, 2012 11:17 AM
Please try as below
.
LOOP AT xvbap where prctr is not initial.
ENDLOOP.
if sy-subrc ne 0 " Meaning no line item has profit center. perform your logic below.
LOOP AT xvbap.
IF xvbap-prctr IS INITIAL.
lv_posnr = xvbap-posnr.
CONDENSE lv_posnr.
CALL FUNCTION 'BKK_DELETE_LEADING_ZERO'
CHANGING
c_field = lv_posnr.
v_flag = 'X'. "changes here
IF lv_text IS NOT INITIAL.
CONCATENATE lv_text lv_posnr into lv_text SEPARATED BY ','.
ELSE.
lv_text = lv_posnr.
ENDIF.
CLEAR lv_posnr .
ENDLOOP.
fcode = 'ENT1'.
CONCATENATE zmsg_txt lv_text INTO zmsg.
message i000(ZZ) WITH zmsg.
FLAG = 1.
fcode = 'ENT1'.
LEAVE TO SCREEN 4001.
endif.
Edited by: nabheetmadan09 on Feb 1, 2012 3:56 PM
Hi Soumya,
Giving a thought about the scenario you have explained, you need Message if profit centre is initial/blank for any line item.
I would suggest you another approach i do not know how far will it suffice your requirement,
Taking your example Suppose there are 3 line items for a sales order with line item 10, 20 & 30 having profit centers as initial/blank.
You want to assign profit centre for line item 20 only but not for line item 30 since you want it to be blank.
When you code anything with respect to the Profit Center of the Line Item, it will check for
if PC is not initial immaterial whether you want it to be blank or not and in all cases it will give you the message
Instead, create a program which will capture the Line Item number.
1) Give the Line Item numbers to the new Z program, and inside the program export the values to a memory id.
2) Import the same value in MV45AFZZ and then in XVBAP you already have the POSNR for which you want to SAVE inspite it is BLANK
3) if xvbap-posnr = g_import_posnr
then dont give the error message.
else.
give the error message.
endif
Revert for further clarification or is there any mistake in my understanding.
Thanks
Sri
endif.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
104 | |
10 | |
8 | |
7 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.