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

Small query regarding sub-routine pgm for a script

Former Member
0 Likes
652

Hi all...

iam new to this group. i am writing a sub-rotuine for a form. But in that one select query was bouncing. and one more thing is there any way to get BUKRS based on KUNNR.

And please correct my code.

PROGRAM ZDUNNING_TEST.

FORM DUNNING_TEST TABLES in_par STRUCTURE itcsy

out_par STRUCTURE itcsy.

DATA: w_po_line_ds LIKE out_par,

w_kunnr LIKE mhnd-kunnr,

w_wrbtr type bsid-wrbtr,

l_index like sy-tabix,

sum like bsid-wrbtr,

w_wrbtr1(15) type c,

w_wrbtr2(15) type c.

CONSTANTS: c_waers_eur(5) type C value 'EUR',

c_waers_usr(5) type C value 'USR',

c_bukrs(4) type c value '5E50'.

data: begin of itab occurs 0,

waers like bsid-waers,

wrbtr like bsid-wrbtr,

end of itab.

data: begin of wa_itab,

waers like bsid-waers,

wrbtr like bsid-wrbtr,

end of wa_itab.

CONSTANTS: c_line(15) TYPE c VALUE 'W_DUN_AMT' .

READ TABLE in_par TRANSPORTING NO FIELDS.

w_kunnr = in_par-value.

*select single bukrs from bsid into w_bukrs where kunnr = w_kunnr.

select waers

wrbtr

from bsid

into table itab

where kunnr = w_kunnr

and bukrs = c_bukrs.

clear sum.

sort itab by waers.

loop at itab into wa_itab.

l_index = sy-tabix.

sum = sum + wa_itab-wrbtr.

at end of waers.

read table itab into wa_itab index l_index.

wa_itab-wrbtr = sum.

move wa_itab-wrbtr to w_wrbtr2.

*write:/ wa_itab-cur,wa_itab-amt.

clear sum.

endat.

endloop.

5 REPLIES 5
Read only

Former Member
0 Likes
627

Hi,

1)

Instead of TRANSPORTING NO FIELDS..use INDEX 1...If you say transporting no fields..No fields will be moved to the header line.

READ TABLE in_par <b>INDEX 1</b>.

2) The customer can be in multiple company codes..

If you want the first company code..Use the following..

DATA: V_BUKRS LIKE KNB1-BUKRS

SELECT SINGLE BUKRS FROM KNB1

INTO V_BUKRS

WHERE KUNNR = 'CUSTOMER NUMBER'.

Thanks,

Naren

Read only

0 Likes
627

Hi Narendran...

Thanks for the reply. But it is bouncing on the select query only.

please check this and corect that.

thanks & regards,

Arjun Jain

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
627

You can get the company code of the customer from table KNB1.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
627

Hi,

Try calling the FM CONVERSION_EXIT_ALPHA_INPUT..

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = W_KUNNR

IMPORTING

OUTPUT = W_KUNNR.

Thanks,

Naren

Read only

Former Member
0 Likes
627

i got of my own...thanks for the help guys...