2013 Jun 29 8:57 AM
Hi all,
i have a need to stop printing my smartform, according to the criteria that for a particular Ref. Doc., i have to see the list of Material Document.
If the last value of Material Document have a movement type "102", then it wouldn't get printed.
I have written this code but not getting desired result, please anyone correct my code(after seeing the screenshot).
DATA : ls_mseg type mseg,
it_mseg type mseg,
it_mseg1 type mseg,
it_mseg2 type mseg.
LOOP AT RG_MBLNR.
clear: ls_mseg.
select single * from mseg into ls_mseg
where mblnr in RG_MBLNR.
select single lfbnr from mseg into it_mseg where lfbnr = mseg-belnr.
select * from mseg into it_mseg1 where lfbnr = mseg-lfbnr.
select max( belnr ) from mseg into it_mseg2 where belnr = RG_MBLNR.
ENDSELECT.
IF sy-subrc eq 0.
DELETE RG_MBLNR.
ENDIF.
ENDLOOP.
2013 Jun 29 9:40 AM
Hi Sanjiv,
First put break point in that enhancement check what your are getting in RG_MBLNR and ls_mseg-bwart
DATA : ls_mseg type mseg.
Break-point.
LOOP AT RG_MBLNR.
clear: ls_mseg.
select single * from mseg into ls_mseg where mblnr in RG_MBLNR.
IF ls_mseg-bwart = '102'.
DELETE RG_MBLNR.
ENDIF.
ENDLOOP.
Hi all,
i have a need to stop printing my smartform, according to the criteria that for a particular Ref. Doc., i have to see the list of Material Document.
If the last value of Material Document have a movement type "102", then it wouldn't get printed.
I have written this code but not getting desired result, please anyone correct my code(after seeing the screenshot).
DATA : ls_mseg type mseg,
it_mseg type mseg,
it_mseg1 type mseg,
it_mseg2 type mseg.
LOOP AT RG_MBLNR.
clear: ls_mseg.
select single * from mseg into ls_mseg
where mblnr in RG_MBLNR.
select single lfbnr from mseg into it_mseg where lfbnr = mseg-belnr.
select * from mseg into it_mseg1 where lfbnr = mseg-lfbnr.
select max( belnr ) from mseg into it_mseg2 where belnr = RG_MBLNR.
ENDSELECT.
IF sy-subrc eq 0.
DELETE RG_MBLNR.
ENDIF.
ENDLOOP.
2013 Jun 29 9:28 AM
Hi All,
please see this edited code, and do the needful
DATA : ls_mseg type mseg,
it_mseg type mseg,
it_mseg1 type mseg,
it_mseg2 type mseg.
LOOP AT RG_MBLNR.
clear: ls_mseg.
select single * from mseg into ls_mseg
where mblnr in RG_MBLNR.
select single lfbnr from mseg into it_mseg where lfbnr = mseg-belnr.
select * from mseg into it_mseg1 where lfbnr = mseg-lfbnr.
select max( belnr ) from mseg into it_mseg2 where belnr = RG_MBLNR
AND bwart = '102'.
ENDSELECT.
IF sy-subrc eq 0.
DELETE RG_MBLNR.
ENDIF.
ENDLOOP.
2013 Jun 29 9:40 AM
Hi Sanjiv,
First put break point in that enhancement check what your are getting in RG_MBLNR and ls_mseg-bwart
DATA : ls_mseg type mseg.
Break-point.
LOOP AT RG_MBLNR.
clear: ls_mseg.
select single * from mseg into ls_mseg where mblnr in RG_MBLNR.
IF ls_mseg-bwart = '102'.
DELETE RG_MBLNR.
ENDIF.
ENDLOOP.
2013 Jun 29 9:56 AM
Hi,
Is this code used in any BADI implementation or a custom program from where you are printing.
DATA : lt_mseg TYPE STANDARD TABLE OF mseg,
wa_mseg TYPE mseg,
wa_mblnr TYPE mseg.
SELECT SINGLE *
FROM mseg
INTO wa_mblnr
WHERE mblnr = rg_mblnr.
IF sy-subrc = 0.
SELECT *
FROM mseg
INTO TABLE lt_mseg
WHERE belnr = wa_mblnr-belnr.
IF sy-subrc = 0.
SORT lt_mseg BY mblnr DESCENDING belnr.
CLEAR : wa_mblnr.
READ TABLE lt_msge INTO wa_mblnr INDEX 1.
IF sy-subrc = 0.
**** Verify the wa_mblnr-bwart value here, if 102 don' issue print.
ENDIF.
ENDIF.
Thanks & Regards
Bala Krishna
2013 Jun 29 10:02 AM
2013 Jun 29 12:07 PM
Hi Bala,
i am doing an enhancement in MB90, in which it is desired that when we enter any Document No. in MB90, it is referred as MBLNR, now whenever any PO gets revarsal, then for that it forms an reference
no, now according to the screenshot, there are single REF. DOC. for which there are many Material Doc. exist, now i need to select the last MATERIAL DOCUMENT, and if the value of it is SAME as that
of the MBLNR value , we have entered in MB90, and its bwart is "102", then it wouldn't gets printed.
If the value of MBLNR we entered in MB90 is same as that of the last value in BELNR and the movement type is "101", then it gets printed.
From my last post i came to know that the value we entered as Material Doc. in MB90 is in DISP-MBLNR, but when i debug MB90, i get MBLNR in RG_MBLNR, so i have written select -option accordingly.
Seeing my present scenario please sujjest me the code that will fill my requirement.
2013 Jun 29 2:36 PM
Hi Sanjeev,
Why are you looking for the last material document? You should only check if that particular document is reversed or not. Your logic will not work if you do the partial GR's.
As per your screenshot below are your material documents.
5..466 101
5..467 102
5..468 101
5..469 102
5..470 101
Logically speaking, if you run MB90 for 5..466 or 5..468, it shouldn't print because they all were reversed. If you run MB90 for 5..470, it should print because it is not reversed.
However, if you still want to work with your logic, you can get the list of material documents from EKBE table. Just get the PO number(EKBE-EBELN) and line item number (EKNE-EBELP) from EKBE where BELNR = MBLNR. Once you found the PO and Line item number, get the list of relevant material documents from the same table EKBE where EBELN and EBELP from the previous query.
Regards,
Asik.
2013 Jun 29 10:18 AM
DATA : It_mseg type mseg,
wa_mseg type mseg.
Select * from mseg into table it_mseg where mblnr = rg_mblnr and mjahr = pm_mjahr.
Loop at it_mseg into wa_mseg.
IF wa_mseg-bwart = '102'.
DELETE RG_MBLNR.
ENDIF.
clear wa_mseg.
ENDLOOP.
2013 Jun 29 12:34 PM
Hello Ramesh,
please tell me what is the need of mjahr field in this. i am not getting your points properly,
please specify clearly, why you have taken it into consideration.
2013 Jun 29 12:41 PM
Hi Sanjeev,
mjahr field specifies year of the material document
2013 Jun 29 1:03 PM
Hello Ramesh,
i know its Material Document Year, but what is its use.
See my requirment is that"when i will enter Material Doc. No. in MB90, it will see its ref. doc. field,
then through this ref. doc, it will see how many Material Doc for this are there (see the screenshot), then it will go for the last Material Doc., if the value of the Material Doc. i enters in MB90 is equal to last Material Doc. in the table
(as in screenshot), then only my smartform gets printed,otherwise not".
For this please do needful.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |