Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

FUNCTION MODULE FOR CHANGING HEADER TEXT FOR GOODS ISSUE DOCUMENT

Former Member
0 Likes
1,877

Hi experts,

i want to change the header text (mkpf-bktxt) of the goods issue document , for this purpose any fn is there

please suggest.

2 REPLIES 2
Read only

Former Member
0 Likes
730

Hi,

Use SAVE_TEXT FM

Read only

Former Member
0 Likes
730

Mohan,

use:'WS_DELIVERY_UPDATE'.

or:

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

also:

LE_MOB_DELIVERY_UPDATE
BAPI_OUTB_DELIVERY_CHANGE'

Amit.

Edited by: Amit on Jun 20, 2008 2:38 PM