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

PAI CODE......plz urgent

Former Member
0 Likes
1,105

hi experts,

i am new to ABAP.

CAN anyone help me with this code.

CODE IN PAI after using popup_to_confirm. function module

i have to insert the itab data from screen to ztable .this is module pool program.

IF answer = '1'. " YES.

SELECT name

id

salary

designation

FROM zdialog

INTO TABLE itab.

LOOP AT itab. "internal table name is itab

zdialog-name = itab-name. "zdialog is the Ztable .

zdialog-id = itab-id.

zdialog-salary = itab-salary.

zdialog-designation = itab-designation.

*****Update the entries into item table*****

INSERT zdialog CLIENT SPECIFIED FROM TABLE itab .

ENDLOOP.

IF sy-subrc = 0.

MESSAGE s000(0) WITH 'data saved successfully'.

ENDIF.

ELSEIF answer = '2'. " NO

LEAVE TO SCREEN 0.

ELSEIF answer = 'A'. " CANCEL

LEAVE PROGRAM.

ENDIF.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
954

Hi Nani,

If you are using the code that you provided,then the names of the fileds in the screen should have the same name as that of the internal tablei.e.,

itab-name.

itab-id.

itab-salary.

itab-designation.

Because in the code that you provided for YES option, you are moving the values from the internal table ITAB to ZDIALOG.But ITAB is not holding the data from the screen.So you need to give the field names in the screen also with the internal table names like the format as above.

By doing so,the field name in the screen will be directly linked to the internal table fields.So when you enter some data in the screen,they will be saved in the internal table.

and I dont think there will be a need of the select querry in the YES option.

So the code will be like this:

IF answer = '1'. " YES.

LOOP AT itab. "internal table name is itab

zdialog-name = itab-name. "zdialog is the Ztable .

zdialog-id = itab-id.

zdialog-salary = itab-salary.

zdialog-designation = itab-designation.

*****Update the entries into item table*****

INSERT zdialog CLIENT SPECIFIED FROM TABLE itab .

ENDLOOP.

Revert for any other querries.

Reward points if helpfull.

Regards,

Kashyap

7 REPLIES 7
Read only

Former Member
0 Likes
955

Hi Nani,

If you are using the code that you provided,then the names of the fileds in the screen should have the same name as that of the internal tablei.e.,

itab-name.

itab-id.

itab-salary.

itab-designation.

Because in the code that you provided for YES option, you are moving the values from the internal table ITAB to ZDIALOG.But ITAB is not holding the data from the screen.So you need to give the field names in the screen also with the internal table names like the format as above.

By doing so,the field name in the screen will be directly linked to the internal table fields.So when you enter some data in the screen,they will be saved in the internal table.

and I dont think there will be a need of the select querry in the YES option.

So the code will be like this:

IF answer = '1'. " YES.

LOOP AT itab. "internal table name is itab

zdialog-name = itab-name. "zdialog is the Ztable .

zdialog-id = itab-id.

zdialog-salary = itab-salary.

zdialog-designation = itab-designation.

*****Update the entries into item table*****

INSERT zdialog CLIENT SPECIFIED FROM TABLE itab .

ENDLOOP.

Revert for any other querries.

Reward points if helpfull.

Regards,

Kashyap

Read only

0 Likes
954

hi kashyap,

thanks for the reply.

i have copied ans pasted the same thing .but internal table fields are not inserting into database table.my Ztable and itab is having the same structure.but still the problem arises.when i insert the fields (example:name as AAAA,id as 1,salary as 1000,designation as CLERK),the data inserting in the ztable is (name as empty,id as 0000,salary as empty and designation as empty)

my version is 4.6c.

can u help me.here i m copying the whole code i have done.

REPORT zdialog1 .

TABLES:zdialog.

DATA:itab TYPE TABLE OF zdialog WITH HEADER LINE.

&----


*& Module USER_COMMAND_1000 INPUT

&----


  • text

----


MODULE user_command_1000 INPUT.

CASE sy-ucomm.

WHEN 'SAVE'.

DATA:answer TYPE c.

CALL FUNCTION 'POPUP_TO_CONFIRM'

EXPORTING

  • TITLEBAR = ' '

  • DIAGNOSE_OBJECT = ' '

text_question = 'would u like to save data?'

text_button_1 = 'YES'(001)

  • ICON_BUTTON_1 = '1'

text_button_2 = 'NO'(002)

  • ICON_BUTTON_2 = '2'

default_button = '1'

display_cancel_button = 'X'

  • USERDEFINED_F1_HELP = ' '

  • START_COLUMN = 25

  • START_ROW = 6

  • POPUP_TYPE =

IMPORTING

answer = answer

  • TABLES

  • PARAMETER =

EXCEPTIONS

text_not_found = 1

OTHERS = 2

.

IF sy-subrc <> 0.

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

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

ENDIF.

IF answer = '1'. " YES.

LOOP AT itab. "internal table name is itab

zdialog-name = itab-name. "zdialog is the Ztable .

zdialog-id = itab-id.

zdialog-salary = itab-salary.

zdialog-designation = itab-designation.

*****Update the entries into item table*****

INSERT zdialog CLIENT SPECIFIED FROM TABLE itab .

ENDLOOP.

IF sy-subrc = 0.

MESSAGE s000(0) WITH 'data saved successfully'.

ENDIF.

ELSEIF answer = '2'. " NO

LEAVE TO SCREEN 0.

ELSEIF answer = 'A'. " CANCEL

LEAVE PROGRAM.

ENDIF.

ENDCASE.

ENDMODULE. " USER_COMMAND_1000 INPUT

Read only

0 Likes
954

Hi Nani,

Insted of using INSERT zdialog CLIENT SPECIFIED FROM TABLE itab .

Use MODIFY zdialog.

i guess this should be helpfull.

Revert for any other querries.

Regards,

Kashyap

Read only

0 Likes
954

hi kashyap,

thanks for answering my question.

but still my problem remains the same.

can u help me?

is there any other way for solving this?

Read only

0 Likes
954

Hi Nani,

Remove the loop and endloop if only a single entry is being passed into the ITAB.

Loop....endloop are used when more than one enttry is to be inserted into ZTable.

Try this code once again:

REPORT zdialog1 .

TABLES:zdialog.

DATA:itab TYPE TABLE OF zdialog WITH HEADER LINE.

&----


*& Module USER_COMMAND_1000 INPUT

&----


text

-


MODULE user_command_1000 INPUT.

CASE sy-ucomm.

WHEN 'SAVE'.

DATA:answer TYPE c.

CALL FUNCTION 'POPUP_TO_CONFIRM'

EXPORTING

TITLEBAR = ' '

DIAGNOSE_OBJECT = ' '

text_question = 'would u like to save data?'

text_button_1 = 'YES'(001)

ICON_BUTTON_1 = '1'

text_button_2 = 'NO'(002)

ICON_BUTTON_2 = '2'

default_button = '1'

display_cancel_button = 'X'

USERDEFINED_F1_HELP = ' '

START_COLUMN = 25

START_ROW = 6

POPUP_TYPE =

IMPORTING

answer = answer

TABLES

PARAMETER =

EXCEPTIONS

text_not_found = 1

OTHERS = 2

.

IF sy-subrc 0.

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

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

ENDIF.

IF answer = '1'. " YES.

zdialog-name = itab-name. "zdialog is the Ztable .

zdialog-id = itab-id.

zdialog-salary = itab-salary.

zdialog-designation = itab-designation.

*****Update the entries into item table*****

INSERT INTO ZDIALOG VALUES ZDIALOG.

IF sy-subrc = 0.

MESSAGE s000(0) WITH 'data saved successfully'.

ENDIF.

ELSEIF answer = '2'. " NO

LEAVE TO SCREEN 0.

ELSEIF answer = 'A'. " CANCEL

LEAVE PROGRAM.

ENDIF.

ENDCASE.

ENDMODULE. " USER_COMMAND_1000 INPUT

If the above code is still not working,create a WORK AREA of the same structure as ZDIALOG.

Move the values of ITAB into that WORK AREA and append the values of the WORK AREA into ZDIALOG.

Also check if the function module that you are using is meets your requirement or not.

And the options for yes and no in the function module are correct or not i.e., 1 , 2 and A.

If the problem is with fucntion module,then use this function module:

DATA : answer type c.

***Call funtion to display popup asking for save or not*****

CALL FUNCTION 'C14A_POPUP_SAVE_WITH_CANCEL'

IMPORTING

e_answer = answer.

IF answer = 'N'.

***Leaving the program****

LEAVE PROGRAM.

ELSEIF answer = 'J'.

****Holding the data on the screen when YES is selected****

set hold data on.

ENDIF.

Here in the function module, N is for No and J is for Yes.

You can put your code for Yes and No respectively.

Reward if helpfull.

Revert for any other querries.

Regards,

Kashyap Ivaturi

Read only

0 Likes
954

Hi Kashyap,

Thanks for the reply.

it helped me a lot.

I rewarded full poins to u.

if u don't mind can u send me ur phone number or ur e-mail id to my personal mail id at aaishu17@yahoo.co.in

Thank you once again.

Read only

Former Member
0 Likes
954

Nani,

If your Itab and Zdialog are of identical structure, then just

INSERT zdialog CLIENT SPECIFIED FROM TABLE itab will do.

You need not loop the itab.

Vinodh Balakrishnan