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

sapscript -- using se38

Former Member
0 Likes
1,514

FORM get_lgpbe TABLES in_par STRUCTURE itcsy

out_par STRUCTURE itcsy.

DATA: lv_matnr TYPE mard-matnr,

lv_lgort TYPE mard-lgort,

lv_lgpbe TYPE mard-lgpbe.

LOOP AT in_par.

CASE in_par-name.

WHEN 'LGORT'.

MOVE in_par-value TO lv_lgort.

WHEN 'MATNR'.

MOVE in_par-value TO lv_matnr.

ENDCASE.

ENDLOOP.

<b>SELECT SINGLE lgpbe INTO lv_lgpbe

FROM mard

WHERE matnr = lv_matnr

and lgort = lv_lgort</b> .

LOOP AT out_par.

CASE out_par-name.

WHEN 'EXT_LGPBE'.

move lv_lgpbe to out_par-value .

ENDCASE.

MODIFY out_par.

ENDLOOP.

ENDFORM. "get_lgpbe

this is my program

if i made this select

<b>SELECT SINGLE lgpbe INTO lv_lgpbe

FROM mard

WHERE matnr = lv_matnr

and lgort = lv_lgort</b> .

in se16 i get value but in the program i dont get' why?

thanks.

1 ACCEPTED SOLUTION
Read only

athavanraja
Active Contributor
0 Likes
1,492

check whether you get proper value passed ot lv_matnr

also just before the select statement add the following code

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

EXPORTING

input = lv_matnr

IMPORTING

OUTPUT = lv_matnr

EXCEPTIONS

LENGTH_ERROR = 1

OTHERS = 2 .

Regards

Raja

13 REPLIES 13
Read only

Former Member
0 Likes
1,492

Hi

Perhaps the code of material number is wrong, infact you have the code in output format (because you're using the value got out from sapscript) and it can have a differen value so your query is failing.

Try that:

LOOP AT IN_PAR.

CASE IN_PAR-NAME.

WHEN 'LGORT'.

MOVE IN_PAR-VALUE TO LV_LGORT.

WHEN 'MATNR'.

MOVE IN_PAR-VALUE TO LV_MATNR.

  • Convertion for input format:

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

EXPORTING

INPUT = LV_MATNR

IMPORTING

OUTPUT = LV_MATNR.

ENDCASE.

ENDLOOP.

Max

Read only

athavanraja
Active Contributor
0 Likes
1,493

check whether you get proper value passed ot lv_matnr

also just before the select statement add the following code

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

EXPORTING

input = lv_matnr

IMPORTING

OUTPUT = lv_matnr

EXCEPTIONS

LENGTH_ERROR = 1

OTHERS = 2 .

Regards

Raja

Read only

0 Likes
1,492

i have lv_ebeln he need this function too

Read only

0 Likes
1,492

foe ebeln use FM

CONVERSION_EXIT_ALPHA_INPUT

to find out which conversion exit to use, check the underlying domain to see the conversion FM

Regards

Raja

Message was edited by: Durairaj Athavan Raja

Read only

0 Likes
1,492

for another select i made this

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

EXPORTING

input = lv_matnr

IMPORTING

OUTPUT = lv_matnr

EXCEPTIONS

LENGTH_ERROR = 1

OTHERS = 2 .

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = lv_ebeln

IMPORTING

OUTPUT = lv_ebeln

.

SELECT SINGLE uptyp INTO lv_uptyp

FROM ekpo

WHERE ebeln = lv_ebeln

AND matnr = lv_matnr.

and it's not working.help pls

Read only

0 Likes
1,492

Hi

Yes I think you're right.

When you have to use a data got out fro sapscript, you should always check the data domain.

Infact here you can see if it's assigned the routine input/output convertions.

For example:

The domain of your field for material code is MATNR and it has the routine MAT1. So you have to use fm:

CONVERSION_EXIT_MAT1_INPUT

The domain of your field for purchase number is EBELN and it has the routine ALPHA:

CONVERSION_EXIT_ALPHA_INPUT

Generally if the domain has the routine <ROUTINE>, you have to use the fm:

CONVERSION_EXIT_<ROUTINE>_INPUT

Max

Read only

0 Likes
1,492

whats the data type of lv_ebeln?

it has to be type ebeln.

Regards

Raja

Read only

0 Likes
1,492

data: lv_ebeln TYPE ekpo-ebeln,

Read only

0 Likes
1,492

Hi

Yes, FM CONVERSION_EXIT_ALPHA_INPUT is right, see my previous answer.

Max

Read only

0 Likes
1,492

why i dont get value and in se16 i get

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

EXPORTING

input = lv_matnr

IMPORTING

OUTPUT = lv_matnr

EXCEPTIONS

LENGTH_ERROR = 1

OTHERS = 2.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = lv_ebeln

IMPORTING

OUTPUT = lv_ebeln.

SELECT SINGLE uptyp INTO lv_uptyp

FROM ekpo

WHERE ebeln = lv_ebeln

AND matnr = lv_matnr.

if lv_uptyp = 2.

lv_bonus = 'X'.

endif.

Read only

0 Likes
1,492

Hi

Are you sure there's the record you're looking for?

Your code is correct but you shouldn't use SELECT SINGLE statament because you aren't using all fields key.

If in your order there are more items than one with the same material, SELECT SINGLE statament'll always give the first record.

SELECT uptyp INTO lv_uptyp FROM ekpo

WHERE ebeln = lv_ebeln

AND matnr = lv_matnr.

if lv_uptyp = 2.

lv_bonus = 'X'.

exit.

endif.

endselect.

Max

Read only

0 Likes
1,492

it's not workin i add ebelp too

SELECT single uptyp INTO lv_uptyp

FROM ekpo

WHERE ebeln = lv_ebeln

AND matnr = lv_matnr

AND EBELP = lv_line.

Read only

0 Likes
1,492

Make sure the field lv_line is correctly filled and try this:

data: w_ekpo like ekpo.

BREAK-POINT.

SELECT single * INTO w_ekpo FROM ekpo

WHERE ebeln = lv_ebeln

aND EBELP = lv_line.

IF lv_matnr = w_ekpo-matnr.

lv_uptyp = W_EKPO-UPTYP.

ENDIF.

Max