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

Modify statement in user exit not working

Former Member
0 Likes
1,525

Hello Everyone,

Following is the code i have written in the user exit for the transaction VT01N.

This code is giving run time error after <u>Modify</u> statement .

Please go thro' the code and help me in solving the error.

DATA: g_vendor.

DATA: BEGIN OF ivlkpa OCCURS 0,

g_vendor LIKE vlkpa-kunde,

g_vbeln LIKE vlkpa-vbeln,

tknum like i_xvttp_tab-tknum,

END OF ivlkpa.

IF i_xvttp_tab[] IS NOT INITIAL.

SELECT kunde vbeln INTO TABLE ivlkpa

FROM vlkpa

FOR ALL ENTRIES IN i_xvttp_tab

WHERE vbeln = i_xvttp_tab-vbeln

AND parvw = 'SP'. " Alias for Carrier Partner function(CR) is SP.

ENDIF.

LOOP AT ivlkpa.

  • READ TABLE i_xvttk_tab with key tknum = ivlkpa-tknum.

  • read table i_xvttk_tab

  • with key vbeln = i_xvttp_tab-vbeln.

*read table i_xvttk_tab

*with key tknum = ivlkpa-tknum.

*read table i_xvttk_tab index 1.

i_xvttk_tab-tdlnr = ivlkpa-g_vendor.

*MOVE ivlkpa-g_vendor TO I_XVTTK_TAB-TDLNR.

MODIFY i_xvttk_tab.

ENDLOOP.

The runtime error which i get after debugging is..

you attempted to change,delete or create a line in the internal table :\PROGRAM=SAPMV56A\DATA=XVTTK[]" but no valid cursor exists for the table.

Thanks,

Sonal

11 REPLIES 11
Read only

Former Member
0 Likes
1,303

write

modify i_xvttk_tab index sy-tabix. "pass index as per ur need

Read only

Former Member
0 Likes
1,303

here index command is missing for modify.

LOOP AT ivlkpa.

READ TABLE i_xvttk_tab with key tknum = ivlkpa-tknum.

  • read table i_xvttk_tab

  • with key vbeln = i_xvttp_tab-vbeln.

*read table i_xvttk_tab

*with key tknum = ivlkpa-tknum.

*read table i_xvttk_tab index 1.

i_xvttk_tab-tdlnr = ivlkpa-g_vendor.

*MOVE ivlkpa-g_vendor TO I_XVTTK_TAB-TDLNR.

if sy-subrc = 0.

MODIFY i_xvttk_tab index sy-tabix..

endif.

ENDLOOP.

please check whether you can read the table i_xvttk_tab with some certain conditions to get the sy-tabix. i hav uncommented the read statement that you have written there may be it is useful.

regards

shiba dutta

Read only

0 Likes
1,303

Thanks Shiba....!!

My code is working now....and i have assign points to u

But still i feel there is problem in my <u>read statement</u>....

can u just see the code which i have written and suggest me whether it is correct...

DATA: g_vendor.

DATA: BEGIN OF ivlkpa OCCURS 0,

g_vendor LIKE vlkpa-kunde,

g_vbeln LIKE vlkpa-vbeln,

tknum like i_xvttp_tab-tknum,

END OF ivlkpa.

IF i_xvttp_tab[] IS NOT INITIAL.

SELECT kunde vbeln INTO TABLE ivlkpa

FROM vlkpa

FOR ALL ENTRIES IN i_xvttp_tab

WHERE vbeln = i_xvttp_tab-vbeln

AND parvw = 'SP'. " Alias for Carrier Partner function(CR) is SP.

ENDIF.

LOOP at ivlkpa.

read table i_xvttk_tab index sy-tabix.

i_xvttk_tab-tdlnr = ivlkpa-g_vendor.

if sy-subrc = 0.

MODIFY i_xvttk_tab index sy-tabix..

endif.

ENDLOOP.

Read only

0 Likes
1,303

Hi,

DATA: g_vendor.

DATA: BEGIN OF ivlkpa OCCURS 0,

g_vendor LIKE vlkpa-kunde,

g_vbeln LIKE vlkpa-vbeln,

tknum like i_xvttp_tab-tknum,

END OF ivlkpa.

IF i_xvttp_tab[] IS NOT INITIAL.

SELECT kunde vbeln INTO TABLE ivlkpa

FROM vlkpa

FOR ALL ENTRIES IN i_xvttp_tab

WHERE vbeln = i_xvttp_tab-vbeln

AND parvw = 'SP'. " Alias for Carrier Partner function(CR) is SP.

ENDIF.

<b>sort ivlkpa by key field </b>.

LOOP at ivlkpa.

read table i_xvttk_tab <b>where field = ivlkpa-field</b>.

i_xvttk_tab-tdlnr = ivlkpa-g_vendor.

if sy-subrc = 0.

MODIFY i_xvttk_tab index sy-tabix..

endif.

ENDLOOP.

Thanks

Shiva

Read only

0 Likes
1,303

here in read statement you have used index sy-tabix means it will only read the perticular row no. means at first loop pass it will read first row of table i_xvttk_tab in 2nd it will read 2nd row of i_xvttk_tab like that .

why dont you use

read table i_xvttk_tab with key vbeln = ivlkpa-vbeln.

it will be better one.

regards

shiba dutta

Read only

0 Likes
1,303

btw there was no diff between Shiba's and my answer so u shud reward all helpfull answers.

make changes as follows -

DATA: g_vendor.

DATA: BEGIN OF ivlkpa OCCURS 0,

g_vendor LIKE vlkpa-kunde,

g_vbeln LIKE vlkpa-vbeln,

tknum like i_xvttp_tab-tknum,

END OF ivlkpa.

IF i_xvttp_tab[] IS NOT INITIAL.

SELECT kunde vbeln INTO TABLE ivlkpa

FROM vlkpa

FOR ALL ENTRIES IN i_xvttp_tab

WHERE vbeln = i_xvttp_tab-vbeln

AND parvw = 'SP'. " Alias for Carrier Partner function(CR) is SP.

ENDIF.

LOOP at ivlkpa.

read table i_xvttk_tab with key field1 = ivlkpa-field1.

if sy-subrc = 0.

i_xvttk_tab-tdlnr = ivlkpa-g_vendor.

MODIFY table i_xvttk_tab from i_xvttk_tab.

endif.

ENDLOOP.

Read only

0 Likes
1,303

yes it tried that ..but unfortunately VTTK does not have vbeln field..

so it is not programming stlye or wht to use

read read table i_xvttk_tab index sy-index.

do reply..

thanks

Read only

0 Likes
1,303

hello amit,

yes u r right ....

but there is no field common between vttk and vlkpa to use for below option.

read table i_xvttk_tab with key field1 = ivlkpa-field1

reply to this query ...will be helpful...

n yes i have awarded pts to u too...

Read only

0 Likes
1,303

then try this.

if your

data : vtknum like vttk-tknum.

LOOP at ivlkpa.

read table i_xvttp_tab with key vbeln = ivlkpa-vbeln.

if sy-subrc = 0.

read table i_xvttk_tab with key tknum = i_xvttp_tab-tknum.

if sy-subrc = 0.

i_xvttk_tab-tdlnr = ivlkpa-g_vendor.

MODIFY i_xvttk_tab index sy-tabix..

endif.

endif.

ENDLOOP.

regards

shiba dutta

Read only

Former Member
0 Likes
1,303

hi,

this is because of not mentioning the index or transporting in modify.

please use transporting if your adding the new values to fields

thanks

Shiva

Read only

Former Member
0 Likes
1,303

Sonal,

Use below code

MODIFY TABLE i_xvttk_tab FROM ivlkpa Transporting tdlnr .

If you want you can write where condition.

Pls. mark for all useful