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

Problem in validating a field value.

aris_hidalgo
Contributor
0 Likes
519

Hello experts,

I am currently having a hard time analyzing the code below. The code below is a part of a report where it displays certain PO(purchase order) based on the criteria in the selection screen. The report shows the PO's amount, downpayment, GR, Invoice, payment and balance. when I run the report, the payment must have the same value as the invoice but it shows otherwise. So for example, PO number 123456 has an amount of 100, 000 and it's invoice is 50, 000 so the payment must also be 50, 000 and the balance would be PO amount - payment. Anyway, I have posted below the code. I hope you could help me guys. Thanks and take care!

  • t_amount-netwr is the PO amount

  • t_amount-dpamt is the downpayment

  • t_amount-gramt is the goods receipt

  • t_amount-iramt is the invoice receipt

  • t_amount-tramt is the payment

  • t_amount-blamt is the balance

DELETE t_pohistory WHERE hist_type <> 'A'

AND hist_type <> 'E'

AND hist_type <> 'Q'.

LOOP AT t_account.

DELETE it_dtl WHERE ebeln = t_account-ebeln

AND psphi IS initial.

DELETE t_ekpo WHERE ebeln = t_account-ebeln

AND ebelp = t_account-po_item.

t_proj-ebelp = t_account-po_item.

SELECT SINGLE psphi FROM prps INTO t_proj-psphi

WHERE posid = t_account-wbs_elem_e.

CHECK sy-subrc = 0.

LOOP AT t_pohistory WHERE po_item = t_account-po_item

AND ebeln = t_account-ebeln.

t_amount-ebeln = t_account-ebeln.

t_amount-psphi = t_proj-psphi.

ON CHANGE OF t_pohistory-po_item.

CLEAR v_netwr.

SELECT SINGLE netwr FROM ekpo INTO v_netwr

WHERE ebeln = t_account-ebeln

AND ebelp = t_account-po_item.

t_amount-netwr = v_netwr.

ENDON.

CHECK NOT t_amount-psphi IS INITIAL.

IF t_pohistory-pstng_date IN so_augdt.

IF t_pohistory-db_cr_ind = 'H'.

t_pohistory-val_loccur = - t_pohistory-val_loccur.

t_pohistory-val_forcur = - t_pohistory-val_forcur.

t_pohistory-cl_val_loc = - t_pohistory-cl_val_loc.

ENDIF.

IF t_pohistory-hist_type = 'A'.

IF t_pohistory-currency <> 'PHP'.

t_amount-dpamt = t_amount-dpamt + t_pohistory-val_forcur.

ELSE.

t_amount-dpamt = t_amount-dpamt + t_pohistory-val_loccur.

ENDIF.

ELSEIF t_pohistory-hist_type = 'E'.

IF t_pohistory-currency <> 'PHP'.

t_amount-gramt = t_amount-gramt + t_pohistory-val_forcur.

ELSE.

t_amount-gramt = t_amount-gramt + t_pohistory-val_loccur.

ENDIF.

ELSEIF t_pohistory-hist_type = 'Q'.

IF t_pohistory-currency <> 'PHP'.

t_amount-iramt = t_amount-iramt + t_pohistory-val_forcur.

ELSE.

t_amount-iramt = t_amount-iramt + t_pohistory-val_loccur.

ENDIF.

ENDIF.

IF t_pohistory-currency <> 'PHP'.

IF t_pohistory-val_loccur = 0 OR

t_pohistory-val_forcur = 0.

t_amount-tramt = t_amount-dpamt.

ELSE.

t_amount-tramt = ( t_pohistory-cl_val_loc /

( t_pohistory-val_loccur /

t_pohistory-val_forcur ) ) +

t_amount-dpamt.

ENDIF.

ELSE.

t_amount-tramt = t_pohistory-cl_val_loc + t_amount-dpamt.

ENDIF.

IF NOT t_pohistory-cl_val_loc IS INITIAL.

CONCATENATE t_pohistory-mat_doc t_pohistory-doc_year

INTO bkpf-awkey.

SELECT SINGLE * FROM bkpf

WHERE awkey = bkpf-awkey.

SELECT augdt augbl shkzg dmbtr wrbtr FROM bsak

INTO (bsak-augdt,bsak-augbl,bsak-shkzg,

bsak-dmbtr,bsak-wrbtr)

WHERE bukrs = bkpf-bukrs

AND gjahr = bkpf-gjahr

AND belnr = bkpf-belnr.

IF bsak-shkzg = 'H'.

bsak-dmbtr = - bsak-dmbtr.

bsak-wrbtr = - bsak-wrbtr.

ENDIF.

IF t_pohistory-currency <> 'PHP'.

  • IF bsak-augdt GT pa_augdt.

IF bsak-augdt IN so_augdt.

t_amount-tramt = t_amount-tramt + bsak-wrbtr.

ENDIF.

ELSE.

  • IF bsak-augdt GT pa_augdt.

IF bsak-augdt IN so_augdt.

t_amount-tramt = t_amount-tramt + bsak-dmbtr.

ENDIF.

ENDIF.

ENDSELECT.

ENDIF.

IF t_account-distr_perc <> 0.

t_amount-dpamt = ( t_account-distr_perc *

t_amount-dpamt ) / 100.

t_amount-gramt = ( t_account-distr_perc *

t_amount-gramt ) / 100.

t_amount-iramt = ( t_account-distr_perc *

t_amount-iramt ) / 100.

t_amount-tramt = ( t_account-distr_perc *

t_amount-tramt ) / 100.

ENDIF.

ENDIF.

IF t_amount-tramt < 0.

t_amount-tramt = 0.

ENDIF.

t_amount-blamt = t_amount-netwr - t_amount-tramt.

COLLECT t_amount. CLEAR t_amount.

APPEND t_proj.

ENDLOOP.

2 REPLIES 2
Read only

hymavathi_oruganti
Active Contributor
0 Likes
491

if both should have same value, then y r u doing separate calculations for both

u can use t_amount-tramt = t_amount-iramt right!!

Read only

Former Member
0 Likes
491

Hi viraylab

IF t_amount-tramt < 0.

t_amount-tramt = 0.

ENDIF.

t_amount-blamt = t_amount-netwr - t_amount-tramt.

COLLECT t_amount. CLEAR t_amount.

APPEND t_proj.

ENDLOOP.

in this collect will collect the wa into the table internal table. then your are clearing it.

have you assigned the values for t_proj before appending

regards

kishore