FM of reverse PGI..

Dear Friend's,
                   Is there any FM available for Revers Post Goods Issue, its too urgent, i am trying it from yesterday oneards, please suggest  me.

REPORT ZWM_OVERWEIGHT_FIX no standard page heading
message-id zwm.
======================================================================
Program Name : ZWM_OVERWEIGHT_FIX *
Description : Tool to fix Overweight in delivery line item, *
Used All Function module to cancel invoice , *
Reverse the goods issue ,Update Delivery qty,Create *
invoice *
Author : Seshu *
Date : 05/08/2007 *
MODIFICATION HISTORY *
DATE | AUTHOR | CHANGE # | DESCRIPTION OF MODIFICATION *
--|||--
05/08/07| Seshu | DEVK921979 | Initial *
D A T A - D E C L A R A T I O N *******************
Tables
Tables : vbak,
vbap,
vbfa,
likp,
lips,
vbrk,
vbrp.
Internal Tables
data : i_lips like lips occurs 0 with header line,
i_vbap like vbap occurs 0 with header line.
Variables
data : v_deliv like vbfa-vbelv,
v_invoic like vbfa-vbelv.
Data Declaration Part for Post Goods Issue
DATA: l_vbeln LIKE likp-vbeln,
l_vbkok LIKE vbkok,
i_prot LIKE prott OCCURS 0 WITH HEADER LINE,
ef_error_any_0 TYPE c,
ef_error_in_item_deletion_0 TYPE c,
ef_error_in_pod_update_0 TYPE c,
ef_error_in_interface_0 TYPE c,
ef_error_in_goods_issue_0 TYPE c,
ef_error_in_final_check_0 TYPE c,
d_return LIKE bapireturn1.
Internal tables for BAPI Function Module
data : i_cret like BAPIRETURN1 occurs 0 with header line,
i_csucess like BAPIVBRKSUCcESS occurs 0 with header line,
i_ret2 like bapiret2 ,
flag type c,
i_mesg like mesg occurs 0 with header line.
Data Declaration for Invoice Creation
DATA: VBSK_I LIKE VBSK.
data: d_success type c.
DATA: XKOMFK LIKE KOMFK OCCURS 0 WITH HEADER LINE,
XKOMV LIKE KOMV OCCURS 0 WITH HEADER LINE,
XTHEAD LIKE THEADVB OCCURS 0 WITH HEADER LINE,
XVBFS LIKE VBFS OCCURS 0 WITH HEADER LINE,
XVBPA LIKE VBPAVB OCCURS 0 WITH HEADER LINE,
XVBRK LIKE VBRKVB OCCURS 0 WITH HEADER LINE,
XVBRP LIKE VBRPVB OCCURS 0 WITH HEADER LINE,
XVBSS LIKE VBSS OCCURS 0 WITH HEADER LINE,
XKOMFKGN LIKE KOMFKGN OCCURS 0 WITH HEADER LINE.
S E L E C T I O N - S C R E E N ******************
Selection-screen
Selection-screen : begin of block blk with frame title text-001.
parameters : p_vbeln like vbak-vbeln obligatory.
selection-screen : end of block blk.
A T - S E L E C T I O N - S C R E E N ***************
Validation on Sales order
at selection-screen on p_vbeln.
Check the data on VBAK Table
select single vbeln from vbak into vbak-vbeln
where vbeln = p_vbeln.
if sy-subrc ne 0.
message e006 with p_vbeln.
endif.
S T A R T - O F - S E L E C T I O N *******************
Start-of-selection.
break sreddy.
Get the Invoice Number corresponding Sales Order Number
perform get_invoice.
Step 1.
Cancel the Invoice - Transaction VF11
perform cancel_invoice.
Reverse the goods issue
perform reverse_goodsissue.
Get the Order and Delivery Items
perform get_sales_deliv.
Delivery Change
perform Delivery_change.
Create Invoice document
perform invoice_create.
E N D - O F - S E L E C T I O N *******************
end-of-selection.
if flag = 'X'.
message i012 with p_vbeln.
endif.
*& Form get_invoice
Get Invoice Number
FORM get_invoice.
Clear Variables
clear : v_deliv,
v_invoic,
flag.
Get the Delivery Number First
select single vbeln from vbfa into v_deliv
where vbelv = p_vbeln
and vbtyp_n = 'J'.
if sy-subrc ne 0.
message i004 with p_vbeln.
stop.
endif.
Get the Invoice Number
select single vbeln from vbfa into v_invoic
where vbelv = p_vbeln
and vbtyp_n = 'M'.
if sy-subrc ne 0.
message i003 with p_vbeln.
stop.
endif.
ENDFORM. " get_invoice
*& Form cancel_invoice
Cancel the Invoice
FORM cancel_invoice.
clear : i_ret2,
i_cret,
i_csucess.
refresh : i_cret,
i_csucess.
CALL FUNCTION 'BAPI_BILLINGDOC_CANCEL1'
EXPORTING
BILLINGDOCUMENT = v_invoic
TESTRUN =
NO_COMMIT =
BILLINGDATE =
TABLES
RETURN = i_cret
SUCCESS = i_csucess
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = space
IMPORTING
RETURN = i_ret2.
read table i_cret with key type = 'E'.
if sy-subrc ne 0.
message i005 with v_invoic.
stop.
endif.
ENDFORM. " cancel_invoice
*& Form reverse_goodsissue
Reverse the goods Issue
FORM reverse_goodsissue.
Local Variable
data : lv_vbtyp like likp-vbtyp.
clear : i_mesg,
lv_vbtyp.
refresh : i_mesg.
select single vbtyp from likp into lv_vbtyp
where vbeln = v_deliv.
CALL FUNCTION 'WS_REVERSE_GOODS_ISSUE'
EXPORTING
I_VBELN = v_deliv
I_BUDAT = sy-datum
I_COUNT =
I_MBLNR =
I_TCODE =
I_VBTYP = lv_vbtyp
TABLES
T_MESG = i_mesg
EXCEPTIONS
ERROR_REVERSE_GOODS_ISSUE = 1
OTHERS = 2
if sy-subrc ne 0.
message i007 with v_deliv.
endif.
ENDFORM. " reverse_goodsissue
*& Form get_sales_deliv
Get the Sales order and Deliv Items
FORM get_sales_deliv.
Local Variables
data : lv_kwmeng like vbap-kwmeng.
clear : i_lips,
i_vbap.
refresh : i_lips,
i_vbap.
Select the data from LIPS
select * from lips into table i_lips
where vbeln = v_deliv.
if sy-subrc ne 0.
message i008 with v_deliv.
stop.
endif.
sort i_lips by vbeln posnr.
Get the Sales order Item Data.
select * from vbap into table i_vbap
where vbeln = p_vbeln.
if sy-subrc ne 0.
message i006 with p_vbeln.
stop.
endif.
sort i_vbap by vbeln posnr.
Compare delivery Item and Order Items
loop at i_lips.
clear lv_kwmeng.
read table i_vbap with key posnr = i_lips-posnr.
if sy-subrc eq 0.
lv_kwmeng = i_vbap-kwmeng * 2.
if lv_kwmeng >= i_lips-lfimg.
i_lips-lfimg = i_vbap-kwmeng.
modify i_lips.
endif.
endif.
endloop.
ENDFORM. " get_sales_deliv
*& Form Delivery_change
Delivery Update
FORM Delivery_change.
Clear : i_prot.
refresh : i_prot.
Delivery Update
CALL FUNCTION 'LE_MOB_DELIVERY_UPDATE'
EXPORTING
do_commit = 'X'
TABLES
t_delivery_items = i_lips
prot = i_prot
EXCEPTIONS
conversion_overflow = 1
essential_data_missing = 2
error = 3
nothing_to_update = 4
lock_after_update_failed = 5
error_in_delivery_update = 6
OTHERS = 7.
COMMIT WORK.
IF sy-subrc <> 0.
MESSAGE i009 with v_deliv.
endif.
Post Goods Issue
CLEAR: d_return,
i_prot,
l_vbeln,
l_vbkok.
REFRESH i_prot.
CLEAR: ef_error_in_item_deletion_0 ,
ef_error_in_pod_update_0 ,
ef_error_in_interface_0 ,
ef_error_in_goods_issue_0 ,
ef_error_in_final_check_0 .
carry out goods issue
l_vbeln = v_deliv.
l_vbkok-vbeln_vl = l_vbeln.
l_vbkok-wabuc = 'X'.
carry out goods issue
l_vbeln = v_deliv.
l_vbkok-vbeln_vl = l_vbeln.
l_vbkok-wabuc = 'X'.
SET UPDATE TASK LOCAL.
CALL FUNCTION 'WS_DELIVERY_UPDATE'
EXPORTING
vbkok_wa = l_vbkok
synchron = 'X'
no_messages_update = ' '
update_picking = 'X'
commit = 'X'
delivery = l_vbeln
nicht_sperren = 'X'
if_error_messages_send_0 = space
IMPORTING
ef_error_any_0 = ef_error_any_0
ef_error_in_item_deletion_0 = ef_error_in_item_deletion_0
ef_error_in_pod_update_0 = ef_error_in_pod_update_0
ef_error_in_interface_0 = ef_error_in_interface_0
ef_error_in_goods_issue_0 = ef_error_in_goods_issue_0
ef_error_in_final_check_0 = ef_error_in_final_check_0
TABLES
prot = i_prot
EXCEPTIONS
error_message = 1
OTHERS = 2.
if sy-subrc ne 0.
message i010 with v_deliv.
else.
COMMIT WORK .
endif.
ENDFORM. " Delivery_change
*& Form invoice_create
Invoice Creation
FORM invoice_create.
refresh: XKOMFK, XKOMV,
XTHEAD, XVBFS,
XVBPA, XVBRK,
XVBRP, XVBSS.
clear : XKOMFK, XKOMV,
XTHEAD, XVBFS,
XVBPA, XVBRK,
XVBRP, XVBSS,
VBSK_I.
VBSK_I-SMART = 'F'.
XKOMFK-VBELN = v_deliv.
XKOMFK-VBTYP = 'J'.
APPEND XKOMFK.
CALL FUNCTION 'RV_INVOICE_CREATE'
EXPORTING
VBSK_I = VBSK_I
WITH_POSTING = 'C'
TABLES
XKOMFK = XKOMFK
XKOMV = XKOMV
XTHEAD = XTHEAD
XVBFS = XVBFS
XVBPA = XVBPA
XVBRK = XVBRK
XVBRP = XVBRP
XVBSS = XVBSS.
if sy-subrc eq 0.
COMMIT WORK.
flag = 'X'.
else.
message i011 with p_vbeln.
endif.
ENDFORM. " invoice_create
regards,
rewards point.

Similar Messages

  • Reversing PGI without cancelling Excise Invoice

    Hi,
    Is there any process where we can Reverse PGI without cancelling the Commercial Invoice & Excise Invoice and again connecting the same corrected delivery to the old invoice number.
    To be more clear, in delivery if I have picked a wrong batch number (different from the physical dispatched batch) and generated the invoice.  The mistake was identified at a later stage.  So I can't cancell the invoice as it has already been sent to the customer.  But in the system I have to correct the batch number to maintain the correct records.
    Please suggest if any solution is there

    Hi,
    Your excise invoice is created with reference to the billing document and billing document has been created from delivery since PGI has been done.
    You will have to cancel excise invoice using J1IH and cancel your billing document using VF11.
    Reverse PGI using VL09, change batch in the delivery and PGI it again.
    However, you would have new commercial invoice and new excise invoice numbers for the same.
    Nothing can be done to retain the same invoice number using std SAP.
    Regards,
    Amit

  • Restrict excise invoice from proforma invoice after reverse PGI

    Hello experts,
    Our sales flow is stock transfer order-> Fast Delivery-> PGI -> Billing (jex)--> excise invoice
    If we have to reverse the PGI first .System give error (cancel excise invoice first)after cancel excise invoice reverse pgi then cancel proforma invoice (complete).
    But once Again excise invoice  allows me create from cancel billing document.
    My requirement is I want to  restrict excise invoice from billing document which already cancel and reverse post good issue.
    Thanks

    HI G. Lakshmipathi,
    I have checked configuration it same as you suggested.
    I have compared  ABAP code in report MJ1IINI01 with other system ,
    there is code to check the cancellation of proforma invoice
    *Check if proforma is cancelled (Billing type is JEX & VBRK-VBTYP = 'U')
    *For proforma,VBRK-FKSTO is not set as X,but VBRK-RFBSK will be set as E
    IF WA_VBRK-VBTYP = 'U' and WA_VBRK-RFBSK = 'E'.
         MESSAGE e264(8i) WITH j1ii100-vbeln.
       ENDIF.
    But in my system its not shown .
    So how can i activate this message is there any setting in IMG to activate message .

  • Handling unit Management - Reverse PGI issue

    We have an issue in our production system with Reverse PGI-
    Transaction: VL09. We could not able to reverse PGI and we are getting
    an error message saying " *HU Items Material posting is inconsistent"*
    Message: HU General 327. We looked into OSS note and implemented OSS
    note: 805186 with out any luck. Apart from this note we also found an
    utility program note: 586578 - Created program
    HUMSEGCREATE_RECORDS_ISA with out any luck.
    Any help will be appericated.
    Thanks,
    Harish Vepuri

    hi Harish,
    check your customizing.
    I think for VL09 and WM the ?material movements == Bewegungsarten ? are not correct.
    If you do a MM -Movement 601 - the storno-movement is MM-602.
    In WM MM-Movenemt 601 ist related with an WM-Movenent ??601 ?? ( can be changed to other number ).
    The WM-Movement ist connected with stock type 9++.
    This connection is correct.
    In your way the reverse way is not customied correct.
    You have to loock after the WM-Movement of 602 ans check, if the connection ot stock-type is made correct -- the same as 601.
    Hans

  • Reverse PGI

    HI All,
    on 3PL wms when they process IOD it will PGI on sap if WMS  use done in error (iod) it is PGI'd SAP, now on SAP we need to raise a return delivery  and issue credit memo to customer (this is the procedure followed by customer ) iam assuming that there should be a way to rectify the error ie reverse PGI or Cancell the billing document and not to raise the cm
    can some one advise which is the best practise for above scenario
    Thank you
    ash

    HI Ashok,
       If you question is with regard to incorrect delivery (PGI) quantities and inorrect invoice sent. Why dont you use the Proof Of Delivery (POD) functionality. This way before invoicing the customer, your customer will send you the POD document and on the basis of POD qty you invoice your customer.
    Regards
    Raj

  • Reverse PGI for Decentralized WM

    We are moving our business over to ECC 6.0 for IM side and for the decentralized WM side as well. 
    In earlier versions, SAP did not support a Reverse PGI with decentralized.  I need verification that this is still the case to move forward with design.
    Does SAP support Reverse PGI with ECC 6.0 and D-WM?

    Hi,
    have anyone of you guys tried to ask SAP more details about what really prevent the GI to be reversed when WMS is decentralized?
    A possible clue would be the status of HU...
    Thanks
    C

  • How to reverse PGI @ VL09 for delivery with subsequent invoice

    Greetings
    Our business process sometimes requires billing to happen prior to PGI.
    Hence, we have modified copy control settings to allow billing based off delivery creation (rather than PGI delivery).
    No modifications to the item categories and we are using standard movement types 601/602
    My issue is at VL09.
    VL09 will not allow me to reverse without cancelling the billing document.
    I get a message No data available for these selection criteria
    I have checked OMJJ movement type settings and I dont see anything here.
    Can anyone point me in the right direction to customize such a setting if it exists?
    We are using ECC 6.0
    thank you
    Ken

    hi
    your issue as standard behavior , when delivery document  billing status completed ,  you can not do the PGI , when you cancel the billing document then only system will accept PGI ,
    when you cancel the billing document , delivery document billing status will change , so accept PGI
    this status comes based on billing document types , like final billing (f2) delivery billing status comes complete, proforma invoice completed then delivery billing status comes not yet proceed
    this is the why system not accept the PGI for final billing document done
    check proforma billing document delivery PGI
    Regards
    sankar

  • After reversed PGI, how to kept the old delivery document and create new

    Dear expert,'
    My client has an requirement:
    Normal Sales cycle:   SO>DN>PGI...Then company found there are some issues like material is wrong..etc Then they will reverse the PGI, and adjust the DN...But they want kept this DN in status like 'closed' 'rejected'...etc.
    And then they will change the ori SO, then create an new DN, then PGI.
    My questions is how to achieve this point: " kept the old DN in status like 'closed' 'rejected'...etc.  and further create new DN after modified the SO."
    Anybody has any idea, thanks.

    hi,
    there is a process for it in include MV50AFZ1,
    FORM userexit_delete_document.
    in it create an Z table to store the deleted documents.
    for reference.
    regards,
    balajia

  • Error in reversing PGI

    Hi,
    I have a scenario where OBD got created for a STO and it was PGI'ed. After PGI, IBD got auto created. After sometime, we came to know that, the mov. types for some of the items in OBD was wrong which was 603 instead of 641. We observe that mov. type for some of the items was 641 where as for some it was 603. Now, we want to reverse the PGI of OBD and system is throwing an error that first cancel IBD.
    When we try to cancel IBD, system is throwing error that "IBD cancellation is not possible because there are already HUs assigned to it." Now, when I try to delete the assignment of HUs in IBD, system is throwing another error "HU functions outside of the delivery only via unique number assignment."
    Request you to advice me how to resolve this issue.
    Thank you,
    Ravi

    Hi,
    Check the SAP note  1252930
    Also check point no 7 in the SAP note - 1119073.
    Hope the above notes will help to resolve this issue.
    Thanks,
    Ram

  • How to reverse PGI in EWM

    Hi All,
    How do i reverse the PGI which has been posted in EWM system?

    Hi,
    Whenever a Delivery is created then it will be distributed to EWM system for PGI.The EWM consultant will do the respective transactional processing in EWM and it will be directed to the R/3.
    Like wise reversal also has to be initiated in the EWM system there by it will be redirected to r/3.
    Regards,
    Saju.S

  • Reverse PGI but relevant sales order is already deleted.

    Hello,
    We have created a consignment fill up order and completed up to posting goods issue.
    Now we need to reverse the PGI for this delivery, unfortunately the relevant sales order was already deleted.
    Can you kindly advise how to reverse the goods issue?
    Thank you.
    1001ailas

    hi,
    this piece of code states that,
    it is checking the VBELN for some other program and compares and passes the value into VBAK-VBELN
    which has been deleted earlier.
    FORM vbak_select USING value(vs_mandt) LIKE sy-mandt
                           value(vs_vbeln) LIKE vbak-vbeln.
      SELECT SINGLE *
             INTO vbak
             FROM vbak
             WHERE vbeln = vs_vbeln.
      IF sy-subrc > 0 .
        PERFORM auftrag_entsperren USING vs_vbeln.
        IF t180-trtyp EQ chara.
          MESSAGE i303(vl) WITH vs_vbeln.
        ELSE.
          PERFORM message_handling(sapmv50a) USING posnr_low
                                                   '303'
                                                   'E'
                                                   'VL'
                                                   vs_vbeln
                                                   space
                                                   space
                                                   space.
        ENDIF.
      ELSE.
        cvbak = vbak.
        rv50a-vtweg = vbak-vtweg.
        rv50a-spart = vbak-spart.
      ENDIF.
    ENDFORM.                    "vbak_select
    there is only one way here i think so,
    please go to archiving team and get be activated or wait till the date of archiving run and make it active.
    balajia

  • Reverse PGI of delivery using VL09

    Hi ,
    My query is while reversing the delivery using VL09 it has check invoice has cancelled or not . For pro forma invoices we have put the code in MV50AFZ1 to check billing document cancelled(completed) or not . It is working fine and  showing the error message what we have given but in background it is reversal happening.
    When we check in MKPF table for material document (MBLNR) the reversal data updated.
    can you please explain .

    Hi,
    i quess Userexit in MV50AFZ1 is working for VL09? did you check if the userexit is also called (and working correctly) when calling the programm in background?
    regards
    Stefan Seeburger

  • Reversed PGI on the wrong date

    dear sir,
    i created a sto for a material and transferred the material from plant A to B. on 10th Oct,
    now against this material i created an order on 20th October. created delivery .and issued it against order.
    now on 25th..we had to cancel the order and we wanted the material to be in our stock on 20th October.but by mistake the user reversed the doc on 25th. via VL09.deleted the outbound delivery.
    now i am unable to reverse the Material document generated.
    so stock is available on 25th Oct.
    i need this material in my stock on 20th October.
    please suggest me some solution.
    regards
    rahul.

    hi sri,
    thanks for the quick reply. i am mm person, and not much familiar with SD ..but i have some doubts, and i m sorry if doubts are childish.
    We cant reverse the vl09 material document.
    how can i turn the stock into MTO stock, also how will it allow me to backpost the stock on 20th october.
    regards
    rahul.

  • Help reqd for Reverse PGI - VL09

    When i try to a reverse goods issue, using transaction VL09, the following error mesage occurs sometimes - mainly with Batch Split on Bulk Deliveries
    Document ****   does not contain any selectable items
    The document or item entered cannot be adopted.
    The error message mentions something about Suggest Zero lines indicator set ??
    I am confused with the above, your help would be much appreciated
    Thanks
    Tony

    Hi,
    Are you processing VL09 with more number of documents or one by one?
    Thanks
    Krishna.

  • Reverse PGI and execting..

    Dear Genius,
                      Still Iam facing problem while reversing the delivery document..I want
    i) FM for reversing the delivery document
    ii) and have to execute the Reverse documet(F5)
    Please suggest me and expecting ur valuable Replay.

    Hi,
      Any one can help me, my issue.

Maybe you are looking for

  • Cannot delete file ...bug?

    This appears like a bug to me...see if you agree. A file opened for read-only access and memory mapped using the map method of FileChannel cannot be deleted even when the channel is closed. An example of this is the simple Grep.java example from NIO

  • Looking for a PDF app for iPad

    Hi, I'm sure I'm not the only one who's thought of this so I'm a believer that someone has created an app to help me and I can't find it! Pretty much, I'm looking for an app that will allow me to edit PDF's on my ipad and then send it (Via WiFi or Bl

  • Process Chain behavior changed after SP upgrade

    Hi all, we've recently updated SP from SAP_BW 700, SAPKW70016 to SAPKW70021. We realized about a particular process chain behavior: We have many process chains configured to execute the next step "Always" (whatever it happens with the previous proces

  • Application Folder Lag

    Hello, I've wondered this from the day I got my Macbook...why does the applications folder lag? I don't have this problem with any other folder on my computer, and it's reasonably high spec, so I don't expect it. More an annoyance than a problem, and

  • OS X Lion - Can't Install Adobe CS 5.5

    Add this to the growing list of problems I'm having since "upgrading" to Lion yesterday... After the upgrade, my Adobe CS 3 apps would no longer run. I received a prompt telling me that "licensing had stopped working" and I needed to uninstall and re