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

use insert comand

Former Member
0 Likes
905

hi i created a ztable and now by using gui_upload i want to enter a flat file to the that database table

now i need to keep 3 radio buttons on the selection screen they are insert modify and delete by using these radio buttons flat file must be upload according to that condition by using GUI_UPLOAD fm

can anyone help how can we solve it

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
874

Sachin,

What is the Dump you are getting.

Attach the Dump message.

Vinodh Balakrishnan

11 REPLIES 11
Read only

Former Member
0 Likes
874

Hi,

I think u know how to create the radio buttons.After creating tht buttons u want to select whether after pressing the radio button it want to work or after selecting the button we want to press f8.

For first choice u want to write the code on atselection screen,for second choice u want to write code in start of selection.

After getting the file into SAP,as based on the condition like,

if <radio1> = 'X'.

u can write the insert code here

(insert <DB table name> from table <internaltable name>)

elseif <radio2_modify> = 'X'.

modify code here

(modify DB from table internal table)

else.

delete code here.

endif.

Read only

0 Likes
874

hi mahesh

thanks for reply

i already did in the same format what u told

but i am getting dump if possible check the code once and tell me whats the error is

PARAMETERS: FILE LIKE IBIPPARMS-PATH.

DATA: BEGIN OF IT_tmg OCCURS 0,

NAME TYPE ZTMG-NAME,

DOB(10), " TYPE ZTMG-DOB,

GENDER TYPE ZTMG-GENDER,

END OF IT_tmg.

DATA PFILE TYPE STRING.

DATA : WA like ZTMG occurs 0 with header line.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILE.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = 'x'

IMPORTING

FILE_NAME = FILE.

PFILE = FILE.

START-OF-SELECTION.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = PFILE

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = IT_tmg

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.

ELSE.

ENDIF.

*

*

  • LOOP AT IT.

  • WRITE:/ IT-NAME.

  • ENDLOOP.

SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

PARAMETERS : INSERT RADIOBUTTON GROUP G1,

MODIFY RADIOBUTTON GROUP G1,

DELETE RADIOBUTTON GROUP G1.

SELECTION-SCREEN : END OF BLOCK B1 .

*MOVE IT TO WA.

WA-NAME = IT_tmg-NAME.

WA-DOB = IT_tmg-DOB.

WA-GENDER = IT_tmg-GENDER.

IF INSERT = 'X'.

*LOOP AT IT.

INSERT ztmg from table wa.

**ENDLOOP.

*MODIFY .

else.

if modify = 'x'.

update ztmg from table wa.

else.

delete ztmg from table wa.

ENDIF.

ENDIF.

Read only

Former Member
0 Likes
874

Sachin, First append your record to your internal table.

The values are still in our work area.

Vinodh Balakrishnan

Read only

0 Likes
874

hi vinodh

i append all records to internal table \but i am getting the same error

can u please modify my above code if possible and send me back .

Read only

Former Member
0 Likes
875

Sachin,

What is the Dump you are getting.

Attach the Dump message.

Vinodh Balakrishnan

Read only

0 Likes
874

hi vinodh

iam getting dump like this

Exception condition "WRONG_PARAMETER" raised

Read only

0 Likes
874

hi vinodh can u modify the above code in a proper way if poossible

Read only

Former Member
0 Likes
874

Sachin,

I have Modified your program accordingly.

Just copy this program to your System and Replace ZZZ_CAB_TEST_DB with Your Database table in your Program.

*******************************************************************************************************

PARAMETERS: FILE LIKE IBIPPARMS-PATH.

DATA: BEGIN OF IT_tmg OCCURS 0.

Include Structure ZZZ_CAB_TEST_DB.

data : END OF IT_tmg.

DATA PFILE TYPE STRING.

DATA : WA like ZZZ_CAB_TEST_DB occurs 0 with header line.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILE.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

FIELD_NAME = 'x'

IMPORTING

FILE_NAME = FILE.

PFILE = FILE.

START-OF-SELECTION.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = PFILE

HAS_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = IT_tmg

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 not SY-SUBRC eq 0.

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

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

ELSE.

ENDIF.

*

*

SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

PARAMETERS : INSERT RADIOBUTTON GROUP G1,

MODIFY RADIOBUTTON GROUP G1,

DELETE RADIOBUTTON GROUP G1.

SELECTION-SCREEN : END OF BLOCK B1 .

IF INSERT = 'X'.

INSERT ZZZ_CAB_TEST_DB from table IT_tmg.

elseif modify = 'x'.

update ZZZ_CAB_TEST_DB from table IT_tmg.

else.

delete ZZZ_CAB_TEST_DB from table IT_tmg.

ENDIF.

Hope this Helps.

Vinodh Balakrishnan

Read only

0 Likes
874

hi vinodh

here we can get it_tmg is not long enough as error na

Read only

Former Member
0 Likes
874

Sacin Did you replace ZZZ_CAB_TEST_DB with your Table name in all places.

Paste your changed code again

VInodh Balakrishnan

Read only

0 Likes
874

hi vinodh

sorry its mistake of mine checking other program and for that also same internal table name i gave thats why

anyway thanks for helping with lot patience

regards

sachin