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

Urgent: getting error while pressing SAVE button on final grid screen

Former Member
0 Likes
463

Hi ABAPers,

please help me to sort this problem, i want to save the records selected by the user to database table. but when i m pressing save on o/p grid screen its giving error as GETWA_NOT_ASSIGNED.

This is my code

TABLES: plaf,

mara,

makt,

zcdr_d.

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

                          • Type Pools for ALV *************************************

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

TYPE-POOLS: SLIS,

ABAP.

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

                          • TYPES DECLARATION ************************************

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

TYPES:

******Types declaration for the plaf

BEGIN OF ty_plaf,

plnum TYPE plaf-plnum,

matnr TYPE plaf-matnr,

END OF ty_plaf,

******Types declaration for the makt

BEGIN OF ty_makt,

maktx TYPE makt-maktx,

END OF ty_makt.

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

                          • INTERNAL TABLE DECLARATION ***************************

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

DATA:

*---internal table for the type ty_plaf

it_plaf TYPE TABLE OF ty_plaf,

*---internal table for the type t_bseg

it_makt TYPE TABLE OF ty_makt,

*---internal table for fieldcat

it_fcat TYPE TABLE OF slis_fieldcat_alv WITH NON-UNIQUE DEFAULT KEY

WITH HEADER LINE INITIAL SIZE 0,

*it_fcat1 TYPE TABLE OF slis_fieldcat_alv WITH NON-UNIQUE DEFAULT KEY

*WITH HEADER LINE INITIAL SIZE 0,

*---internal table for alv events

it_events TYPE TABLE OF slis_alv_event WITH NON-UNIQUE DEFAULT KEY

WITH HEADER LINE INITIAL SIZE 0,

*it_events1 TYPE TABLE OF slis_alv_event WITH NON-UNIQUE DEFAULT KEY

*WITH HEADER LINE INITIAL SIZE 0,

*---final Internal table

BEGIN OF it_final OCCURS 0,

plnum LIKE plaf-plnum,

sel TYPE C,

matnr LIKE plaf-matnr,

maktx LIKE makt-maktx,

END OF it_final,

BEGIN OF it_zcdr_d OCCURS 0,

  • DSEL TYPE C,

CBOOKNO LIKE zcdr_d-CBOOKNO,

PLNUM LIKE zcdr_d-plnum,

MATNR LIKE zcdr_d-matnr,

MAKTX LIKE zcdr_d-maktx,

END OF it_zcdr_d,

*-------to pass the internal table data to database table

itab TYPE TABLE OF zcdr_d with header line,

it_save TYPE TABLE OF zcdr_d with header line.

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

                          • WORK AREA DECLARATION ********************************

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

DATA:

*---workarea for the type ty_plaf

wa_plaf TYPE ty_plaf,

*---workarea for the type ty_makt

wa_makt TYPE ty_makt,

*---workarea for the fieldcatalog

wa_fcat TYPE slis_fieldcat_alv,

wa_final LIKE LINE OF it_final,

*---WORKAREA FOR THE PROCESSED DOCUMENT

wa_zcdr_d LIKE LINE OF it_zcdr_d,

*---LAYA OUT DECLARATION

wa_layout TYPE slis_layout_alv.

*---LAYA OUT DECLARATION

*wa_layout1 TYPE slis_layout_alv.

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

                          • Variables DECLARATION ********************************

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

DATA: v_repid LIKE SY-REPID,

v_hkont LIKE bseg-hkont,

v_pifno(16) TYPE C,

v_pifdat LIKE SY-DATUM,

v_pif(6) TYPE C,

Field_Cat type Slis_T_fieldcat_alv with HEADER LINE,

List_Top_Of_Page type Slis_T_Listheader.

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

                          • PARAMETERS ****************************************

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

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.

PARAMETERS : CBOOKNO(16) TYPE n OBLIGATORY. "Customs Book number

SELECTION-SCREEN END OF BLOCK b1.

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

                          • SELECT OPTION ****************************************

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

SELECTION-SCREEN : BEGIN OF BLOCK blk WITH FRAME TITLE text-001.

SELECTION-SCREEN SKIP 1.

SELECT-OPTIONS:

*----


Date

so_pertr for plaf-pertr,

*----


Material

so_matnr for plaf-matnr,

*----


Material Group

so_matkl for mara-matkl,

*----


Plant

so_plwrk for plaf-plwrk OBLIGATORY,

*----


Sales Order

so_kdauf for plaf-kdauf.

SELECTION-SCREEN : END OF BLOCK blk.

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

                          • LOAD OF PROGRAM ***************************************

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

*LOAD-OF-PROGRAM.

*IF sy-tcode NE text-002. "Condition for TCode Check

    • MESSAGE 'RUN THROUGH THE TRANSACTION CODE' TYPE 'X'.

*ENDIF. "End Condition for TCode

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

                          • INITIALIZATION ****************************************

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

INITIALIZATION.

PERFORM CLEAR_DATA.

CLEAR: wa_layout.

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

                          • START-OF-SELECTION *************************************

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

START-OF-SELECTION.

*-------Getting the data from database

PERFORM GET_DATA.

*-------Populating field catalog

PERFORM populate_fieldcatalog.

PERFORM set_events USING it_events[].

PERFORM top_of_page.

*------Processing the Data and Moving to final Internal Table

*PERFORM PROCESS_DATA.

*------Displaying the data in the Output

PERFORM DISPLAY_OUTPUT.

*end-of-SELECTION.

*call screen 0500.

*

*&----


**& Module d0100_set_status OUTPUT

*&----


    • text

*----


*module d0500_set_status output.

  • data : rt_extab TYPE slis_t_extab.

  • perform set_pf_status USING rt_extab.

*endmodule. " d0100_set_status OUTPUT

*

*

*module d0100_fcode input.

  • perform user_command.

*endmodule. " d0100_fcode INPUT

form CLEAR_DATA .

**CLEARDING THE TABLES AND WORK AREAS

CLEAR: it_plaf[],

it_makt[],

wa_plaf,

wa_makt.

endform. " CLEAR_DATA

*&----


*& Form GET_DATA

*&----


  • text

*----


  • --> p1 text

  • <-- p2 text

*----


form populate_fieldcatalog.

DATA: L_POS TYPE I.

FIELD_CAT-COL_POS = L_POS.

L_POS = L_POS + 1.

CLEAR FIELD_CAT.

field_cat-SELTEXT_M = 'Planned Order Nos.'.

field_cat-tabname = wa_final.

field_cat-fieldname = 'PLNUM'.

append field_cat.

FIELD_CAT-COL_POS = L_POS.

L_POS = L_POS + 1.

CLEAR FIELD_CAT.

*field_cat-checkbox = 'X'.

field_cat-SELTEXT_M = 'Check Box'.

Field_Cat-outputlen = '1'.

field_cat-tabname = wa_final.

field_cat-checkbox = abap_true.

field_cat-edit = abap_true.

field_cat-fieldname = 'CHK'.

append field_cat.

FIELD_CAT-COL_POS = L_POS.

L_POS = L_POS + 1.

CLEAR FIELD_CAT.

field_cat-SELTEXT_M = 'Material'.

field_cat-tabname = wa_final.

field_cat-fieldname = 'MATNR'.

append field_cat.

FIELD_CAT-COL_POS = L_POS.

L_POS = L_POS + 1.

CLEAR FIELD_CAT.

field_cat-SELTEXT_M = 'Material Description'.

field_cat-tabname = wa_final.

field_cat-fieldname = 'MAKTX'.

append field_cat.

endform. " build_fieldcatalog

form GET_DATA .

SELECT

a~PLNUM

a~MATNR

b~MAKTX

c~matkl

INTO CORRESPONDING FIELDS OF TABLE it_final

FROM plaf as a

Inner join makt as b

on amatnr = bmatnr

Inner join mara as c

on cmatnr = bmatnr

where a~pertr in so_pertr

or a~matnr in so_matnr

or c~matkl in so_matkl

or a~kdauf in so_kdauf

or a~plwrk in so_plwrk.

SORT it_final by plnum.

endform. " GET_DATA

FORM TOP_OF_PAGE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = List_Top_Of_Page.

ENDFORM.

*----


form DISPLAY_OUTPUT .

DATA: repid LIKE sy-REPID,

Eventcat type Slis_T_Event,

LAYOUT TYPE SLIS_LAYOUT_ALV.

LAYOUT-COLWIDTH_OPTIMIZE = 'X'.

LAYOUT-ZEBRA = 'X'.

repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = repid

I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

I_GRID_TITLE = 'PLANNED ORDERS'

  • I_GRID_SETTINGS =

IS_LAYOUT = layout

IT_FIELDCAT = Field_Cat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

I_DEFAULT = 'X'

I_SAVE = 'X'

  • IS_VARIANT =

IT_EVENTS = IT_EVENTS[]

TABLES

T_OUTTAB = it_final

EXCEPTIONS

PROGRAM_ERROR = 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.

ENDFORM.

FORM set_events USING it_events TYPE slis_t_event.

DATA: x_event TYPE LINE OF slis_t_event.

clear x_event.

x_event-name = 'USER_COMMAND'.

x_event-form = 'USER_COMMAND'.

append x_event to it_events.

CLEAR x_event.

**

call function 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = IT_EVENTS

EXCEPTIONS

LIST_TYPE_WRONG = 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.

read table it_events into x_event with key name = 'USER_COMMAND'.

if sy-subrc = 0.

x_event-form = 'USER_COMMAND'.

modify it_events from x_event index sy-tabix transporting form .

endif.

ENDFORM.

FORM set_pf_status USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'Z_PFSTAT'.

ENDFORM. "set_pf_status

&----


*& Form user_command

&----


  • text

----


  • -->R_UCOMM text

  • -->RS_SELFIELDtext

----


FORM user_command USING

r_ucomm TYPE sy-ucomm

rs_selfield TYPE slis_selfield. "#EC *

if r_ucomm = '&DATA_SAVE' .

LOOP AT it_final INTO wa_final.

IF wa_final-sel EQ 'X'.

MOVE: wa_final-plnum TO it_save-plnum,

wa_final-matnr TO it_save-matnr,

wa_final-maktx TO it_save-maktx,

v_pifno TO it_save-CBOOKNO,

SY-MANDT TO it_save-mandt.

MOVE it_save to zcdr_d.

*INSERT zcdr_d.

*if l_valid = 'X'.

MODIFY zcdr_d FROM TABLE it_save.

endif.

ENDLOOP.

IF it_save is initial.

MESSAGE 'Select Atleast one Check Box' TYPE 'E' .

ELSE.

*CONCATENATE 'Number ' V_PIFNO ' Genrated'

  • IF SY-SUBRC EQ 0.

MESSAGE S001(zcdr_d) WITH 'Number ' CBOOKNO ' Genrated'.

ENDIF.

endif.

ENDFORM.

Thanks a lot for ur help in advance

Pankaj

2 REPLIES 2
Read only

Former Member
0 Likes
433

Hi Pankaj,

Check out the function code of the SAVE buttton. I somehow feel that the function code being used in the code i.e. <b>&DATA_SAVE</b> is not same as the function code assigned in the GUI status.

<b>Reward points inorder to say thanks,</b>

Kiran

Read only

0 Likes
433

Thanks a lot for the reply Kiran, but i have already checked it, but its the same one. In debugging mode its going for error when there is a call for method like:

call method gt_grid-grid->set_function_code

changing

c_ucomm = l_okcode.

so i dont know where is the problem. & this is in PAI module of the system program.

Thanks

Pankaj