types: begin of ty_msg_str,
sno type i,
pernr_d type pernr_d,
msg type string,
belnr type bseg-belnr,
end of ty_msg_str.
data: gt_fmsg type table of ty_msg_str,
gs_fmsg type ty_msg_str.
data : gt_fieldcat type slis_t_fieldcat_alv,
gs_fieldcat type slis_fieldcat_alv,
gt_layout type lvc_s_layo,
gs_layout type slis_layout_alv.
data : gt_return type table of bapiret2,
gt_return1 type table of bapiret2,
gs_return like line of gt_return,
gt_accountgl type table of bapiacgl09,
gt1_accountgl type table of bapiacgl09,
gs_accountgl like line of gt_accountgl,
gt_accountpayable type table of bapiacap09,
gs_accountpayable like line of gt_accountpayable,
gt_accountreceivable type table of bapiacar09,
gs_accountreceivable like line of gt_accountreceivable,
gt_cur type table of bapiaccr09,
gt_cur1 type table of bapiaccr09,
gs_cur like line of gt_cur,
gs_head type bapiache09,
gt_extention type table of bapiextc,
gs_extention type bapiextc,
gv_amt type char20,
gv_acc type sy-tabix,
lv_itemno(4) type c,
lv_indicator(1) type c,
obj_type type bapiache02-obj_type,
obj_key type bapiache02-obj_key,
obj_sys type bapiache02-obj_sys,
it_extension1 type standard table of bapiacextc,
wa_extension1 type bapiacextc...
data: sum_cur type p decimals 2.
data: lv_ind type i .
***********************************************************************************
form bapi_update.
lv_ind = lv_ind + 1.
refresh:gt_cur1.
move: gt_cur[] to gt_cur1[].
loop at gt_cur into gs_cur.
sum_cur = sum_cur + gs_cur-amt_doccur.
clear: gs_cur.
endloop.
if sum_cur < 0. .
sum_cur = sum_cur * -1.
if sum_cur between '0.0000' and '0.9000'.
sum_cur = sum_cur * -1.
loop at gt_cur into gs_cur.
if gs_cur-amt_doccur > '0' .
gs_cur-amt_doccur = gs_cur-amt_doccur - sum_cur.
modify gt_cur from gs_cur.
exit.
endif.
clear: gs_cur.
endloop.
endif.
endif.
if sum_cur between '0.0000' and '0.9000'.
loop at gt_cur into gs_cur.
if gs_cur-amt_doccur < '0' .
gs_cur-amt_doccur = gs_cur-amt_doccur - sum_cur.
modify gt_cur from gs_cur.
exit.
endif.
clear: gs_cur.
endloop.
endif.
clear: sum_cur.
call function 'BAPI_ACC_DOCUMENT_POST'
exporting
documentheader = gs_head
importing
obj_type = obj_type
obj_key = obj_key
obj_sys = obj_sys
tables
accountgl = gt_accountgl
accountpayable = gt_accountpayable
* EXTENSION1 =
currencyamount = gt_cur
return = gt_return.
read table gt_return into gs_return with key type = 'S'.
if sy-subrc = 0.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'
* IMPORTING
* RETURN =
.
gs_fmsg-sno = lv_ind .
gs_fmsg-pernr_d = pernr_d.
gs_fmsg-msg = 'Document Successfully Posted!!' .
gs_fmsg-belnr = gs_return-message_v2+0(10) .
append gs_fmsg to gt_fmsg .
clear : gs_fmsg ,pernr_d .
refresh gt_return[] .
endif.
loop at gt_return into gs_return where type = 'E' .
gs_fmsg-sno = lv_ind .
gs_fmsg-msg = gs_return-message .
gs_fmsg-pernr_d = pernr_d.
gs_fmsg-belnr = ' '.
append gs_fmsg to gt_fmsg .
clear : gs_fmsg ,pernr_d ..
clear : gs_return .
endloop .
endform.
*******************************************************************************
form build_layout using value(p_2015)
value(p_2016)
value(p_2017)
value(p_2018)
value(p_2019)
value(p_2020).
gs_fieldcat-col_pos = p_2015.
gs_fieldcat-fieldname = p_2016.
gs_fieldcat-tabname = p_2017.
gs_fieldcat-reptext_ddic = p_2018.
gs_fieldcat-outputlen = p_2019.
gs_fieldcat-do_sum = p_2020.
append gs_fieldcat to gt_fieldcat.
clear : gs_fieldcat .
endform.
*********************************************************************************
form display_bapi_message .
perform build_layout using '1' 'SNO' 'GT_FMSG' 'Record Number' '12' ''.
perform build_layout using '2' 'PERNR_D' 'GT_FMSG' 'Employee Number' '12' ''.
perform build_layout using '3' 'MSG' 'GT_FMSG' 'Message' '45' ''.
perform build_layout using '4' 'BELNR' 'GT_FMSG' 'Accounting Document Number' '10' ''.
gs_layout-colwidth_optimize = 'X'.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_background_id = 'ALV_BACKGROUND'
i_callback_program = sy-repid
it_fieldcat = gt_fieldcat
is_layout = gs_layout
i_save = 'A'
tables
t_outtab = gt_fmsg.
endform.
*************************************************************************
No comments:
Post a Comment