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

alv's

Former Member
0 Likes
1,254

please help me friends,

i want insert data into the database using alv's.

i want to put an insert button on the screen and when i press that button the data should be entered into the database from alv.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,202

Hi,

Check this demo Program ..

<b>BCALV_EDIT_04</b>

Regards

vijay

please help me friends,

i want insert data into the database using alv's.

i want to put an insert button on the screen and when i press that button the data should be entered into the database from alv.

9 REPLIES 9
Read only

Former Member
0 Likes
1,202

hi Chandu,

Refer to this Link for the same

http://www.sap-img.com/abap-function.htm

Regards,

Santosh

Read only

Former Member
0 Likes
1,202

Hi,

the internal table(which you are displaying in alv) you have is to be looped and then the desired records should be inserted into the database.

Loop at itab.

modify database table from itab.

endloop.

Regards,

Aswin

Read only

Former Member
0 Likes
1,203

Hi,

Check this demo Program ..

<b>BCALV_EDIT_04</b>

Regards

vijay

Read only

Former Member
0 Likes
1,202
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
    I_CALLBACK_PROGRAM                = W_REPID
    I_CALLBACK_PF_STATUS_SET          = <b>'PF_STATUS'</b>
    I_CALLBACK_USER_COMMAND           = <b>'USER_COMMAND'</b>

<b>*copy pf status from any standard program , double click on it and add ur new button named insert</b>

FORM PF_STATUS using RT_EXTAB TYPE SLIS_T_EXTAB.

  SET PF-STATUS 'STANDARD1' EXCLUDING RT_EXTAB.

ENDFORM.                    "PF_STATUS


FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM
                        P_SELFLD TYPE SLIS_SELFIELD.
case p_ucomm.
  when 'INSERT'.
    modify ztable from table itab.
endcase.
endform.
Read only

Former Member
0 Likes
1,202

hi

chkout this thread

<b>

Read only

Former Member
0 Likes
1,202

chandu ,

check this link once

Regards,

Naveen

Read only

Former Member
0 Likes
1,202

hi chandu,

check the demo program

<b>BCALV_EDIT_02</b>

hope this helps,

priya.

Read only

Former Member
0 Likes
1,202

Hi Chandu,

Since you want to insert the data into the database it's always advisable to keep an option to revert back if something messes up. What I would do is, keep another button adjacent to 'INSERT' by name 'UNDO' to use in case something goes wrong.

In addition to what chandrasekhar advised you to insert the data, you can do little modification to keep this option.

check this out.

======================================================

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = W_REPID

I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

*copy pf status from any standard program , double click on it and add ur new button named insert

FORM PF_STATUS using RT_EXTAB TYPE SLIS_T_EXTAB.

SET PF-STATUS 'STANDARD1' EXCLUDING RT_EXTAB.

ENDFORM. "PF_STATUS

FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM

P_SELFLD TYPE SLIS_SELFIELD.

case p_ucomm.

when 'INSERT'.

<b> CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = 'C:\upload\test.txt'

FILETYPE = 'ASC'

WRITE_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = ITAB

EXCEPTIONS

FILE_WRITE_ERROR = 1

NO_BATCH = 2

GUI_REFUSE_FILETRANSFER = 3

INVALID_TYPE = 4

NO_AUTHORITY = 5

UNKNOWN_ERROR = 6

HEADER_NOT_ALLOWED = 7

SEPARATOR_NOT_ALLOWED = 8

FILESIZE_NOT_ALLOWED = 9

HEADER_TOO_LONG = 10

DP_ERROR_CREATE = 11

DP_ERROR_SEND = 12

DP_ERROR_WRITE = 13

UNKNOWN_DP_ERROR = 14

ACCESS_DENIED = 15

DP_OUT_OF_MEMORY = 16

DISK_FULL = 17

DP_TIMEOUT = 18

FILE_NOT_FOUND = 19

DATAPROVIDER_EXCEPTION = 20

CONTROL_FLUSH_ERROR = 21

OTHERS = 22.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.</b>

modify ztable from table itab.

<b> when 'UNDO'.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'C:\upload\test.txt'

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = ITAB

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

DELETE ZTABLE FROM TABLE ITAB.

REFRESH ITAB. </b>

endcase.

endform.

======================================================

This is just an advice. It's your convenience to implement this functionality.

Regards,

Vicky

PS: Award points if helpful

Read only

Former Member
0 Likes
1,202

hi chandu,

the easiest way would be to define a button in the status with the function code 'INSR'.

Then in the PAI of the ALV for the condition

case sy-ucomm

WHEN 'INSR'.

here take the data from the internal table used to populate the alv and insert it into the database.

Hope this helps