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

why my program doesnt work - selection screen

Former Member
0 Likes
1,145

Following program is small prog to add data to database.trackid and artist are its fields

REPORT ZGSCREEN no standard page heading

.

tables :zgtable,sscrfields.

data:begin of itable occurs 0,

mandt like zgtable-mandt,

trackid like zgtable-trackid,

artist like zgtable-artist,

end of itable.

selection-screen begin of block block1 with frame title txt1.

parameters:trackid like zgtable-trackid,

artist like zgtable-artist.

selection-screen skip 5.

selection-screen begin of line.

selection-screen pushbutton (20) but1 user-command but1.

selection-screen position 25.

selection-screen pushbutton (8) but2 user-command but2.

selection-screen position 38.

selection-screen pushbutton (10) but3 user-command but3.

selection-screen position 55.

selection-screen pushbutton (10) but4 user-command but4.

selection-screen end of line.

selection-screen end of block block1.

initialization.

but1 = 'Save to Dbase'.

but2 = 'Clear'.

but3 = 'Update'.

but4 = 'Exit'.

move 800 to itable-mandt.

move trackid to itable-trackid.

move artist to itable-artist.

append itable.

at selection-screen.

if sscrfields-ucomm eq'BUT1'.

insert zgtable from itable.

endif.

if sscrfields-ucomm eq 'BUT4'.

leave program.

endif.

****The program is not throwing error but data is not getting saved to database.I dont know why,any idea?

1 ACCEPTED SOLUTION
Read only

former_member195698
Active Contributor
0 Likes
1,114

There is no syntax error in the code, but the way of coding is wrong.

The logic of population the internal table and updating the databse table should in the event start-of-selection.

at selection.-screen is used for validating the data on the screen.

After changing the program, check if still the database is not getting updated.

If not, then write an explicit COMMIT WORK. statement in your report.

Regards,

Abhishek

8 REPLIES 8
Read only

former_member195698
Active Contributor
0 Likes
1,115

There is no syntax error in the code, but the way of coding is wrong.

The logic of population the internal table and updating the databse table should in the event start-of-selection.

at selection.-screen is used for validating the data on the screen.

After changing the program, check if still the database is not getting updated.

If not, then write an explicit COMMIT WORK. statement in your report.

Regards,

Abhishek

Read only

0 Likes
1,114

I changed at-selection screen to start-of-selection...i think the button click even is not getting fired.Help me how to save these two fields to database.

Read only

0 Likes
1,114

As noted above, try putting in a "commit work." ... and perhaps a break-point just before the insert so you can check the logic has reached the right point with the values you expect... also, you have code like "insert XYZ from ABC" but I think you mean "insert XYZ from table ABC"... in addition, you don't need you have "MANDT" in your internal table definition - SAP will take care of this for you based on the current value of sy-mandt (unless you specifically code for "client specified" logic).

Jonathan

Read only

0 Likes
1,114

John,

ok i will try to use breakpoint,but i dont know how to do,it was easy in VB :).Coming to mandt,I used 800 since it was saying 'itable was not long enough'.

Insert XYZ from ABC...where ABC is internal table.

Read only

0 Likes
1,114

Well I reckon ABAP breakpoints are easier than VB, but it's probably what you get used to... when you reach the breakpoint, you can double-click on a single field to show its value... if it's an internal table, just click on the field then the "Table" button to show the contents { depends which ABAP debugger you are running }... or for now you could stick in a few "write" statements to show progress through the code.

As for "mandt", you can leave it in the internal table, but not bother setting it as SAP will do this for you.

If you still have no luck getting it to work, paste a copy of your latest code here, and I can look tomorrow { use the Code button in the SDN message editor to make it clearer }.

cheers

Jonathan

Read only

0 Likes
1,114

*&---------------------------------------------------------------------*
*& Report  ZGSCREEN                                                    *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  ZGSCREEN no standard page heading
.
tables :zgtable,sscrfields.

data:begin of itable occurs 0,
     mandt like zgtable-mandt,
     trackid like zgtable-trackid,
     artist like zgtable-artist,
     end of itable.
selection-screen begin of block block1 with frame title txt1.
parameters:trackid(15) type n, *I changed from trackid like zgtable-trackid
           artist(30) type c.

selection-screen skip 5.

selection-screen begin of line.
selection-screen pushbutton (20) but1 user-command but1.
selection-screen position 25.
selection-screen pushbutton (8) but2 user-command but2.
selection-screen position 38.
selection-screen pushbutton (10) but3 user-command but3.
selection-screen position 55.
selection-screen pushbutton (10) but4 user-command but4.

selection-screen end of line.
selection-screen end of block block1.

initialization.
but1 = 'Save to Dbase'.
but2 = 'Clear'.
but3 = 'Update'.
but4 = 'Exit'.

move 800 to itable-mandt.
move trackid to itable-trackid.
move artist to itable-artist.

append itable.

at selection-screen.
if sscrfields-ucomm eq'BUT1'.

  insert zgtable from itable.
  commit work.
endif.

if sscrfields-ucomm eq 'BUT4'.
leave program.
endif.

Jonathan as you siad I used breakpoints somehow and i clicked the table button.To my suprise the fields doesnt have value,mandt field had 800,trackid had 000000000 and artist field is empty.It mean that data is not added to internal table itself.I dont know why.Hope you will help in clearing it out.One more thing is that is it true that Internet connection and SAP should not be on same OS.So I installed Server 2003 for SAP and XP for internet.I work there and restart,come to XP for forums.Is this the way or any other way where I can use internet and SAP on same OS?I came to know about SAP netweaver server abap trail version in one sap blogs here.Can I download it to XP OS and work in it besides internet connection to same OS(XP).Hope you understood my issue.

Thanks

Read only

0 Likes
1,114

Just quickly, try moving

move 800 to itable-mandt.
move trackid to itable-trackid.
move artist to itable-artist.
append itable.

into the "at selection-screen" because the "initialization." code will only happen as the program loads thus the values in "trackid" and "artist" at that point are empty... but they will have the values you enter in the selection screen when you reach the event "at selection-screen."... also change "insert zgtable from itable." to be "insert zgtable from table itable.".

You probably want to open the other part of this posting (about the trial edition) as a new thread.

Jonathan

Read only

0 Likes
1,114

Thanks Jonathan.Its working.Anyhow I got a error,let me put that in next thread.