cancel
Showing results for 
Search instead for 
Did you mean: 

change the place of fields on the ALV output

Former Member
0 Kudos

Hello Experts,

I have used SALV_WD_TABLE within the WD Abap.

The output meets the requirements as far as. The only one thing is the sequence of the fields.

May I change the placement or the order of the fields on the ALV output?

e.g.

USERID -> Field 1  
PLANT   -> Field2
MATKL  -> Field3
PREIS ->  Field4

change to 


MATKL   -> Field1
PREIS   ->  Field2
USERID -> Field 3  
PLANT   -> Field4

Regards

sas

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I get this message

Acces to 'NULL' Objektreferenz not possible. 
Der Fehler trat auf dem Applikationsserver apslidl_ESR_00 und im Workprozess 0 auf. 
Die Abbruchart war: RABAX_STATE 
Die ABAP-Aufrufhierarchie war: 
Method: WDDOINIT of program /1BCWDY/4DNCYB5TU51WEPL8ZD9X==CP
Method: IF_WDR_VIEW_DELEGATE~WD_DO_INIT of program /1BCWDY/4DNCYB5TU51WEPL8ZD9X==CP
Method: DO_INIT of program CL_WDR_DELEGATING_VIEW========CP
Method: INIT_CONTROLLER of program CL_WDR_CONTROLLER=============CP
Method: INIT_CONTROLLER of program CL_WDR_VIEW===================CP
Method: INIT of program CL_WDR_CONTROLLER=============CP
Method: GET_VIEW of program CL_WDR_VIEW_MANAGER===========CP
Method: BIND_ROOT of program CL_WDR_VIEW_MANAGER===========CP
Method: INIT of program CL_WDR_VIEW_MANAGER===========CP
Method: INIT_CONTROLLER of program CL_WDR_INTERFACE_VIEW=========CP

uday_gubbala2
Active Contributor
0 Kudos

Hi,

Getting a NULL object reference error might be because of many reasons. Go to ST22 and try find out the particular line from which you are getting this exception. You might be getting the error in this particular line:

lr_column = lo_value->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( id = 'SEATSOCC' ).

Make sure that the value that you are passing to the id is exactly the same as to what you have defined in your context. For example you might be having a different attribute name say ATTR1 of type SFLIGHT-SEATSOCC in your context. Then you would have to pass ATTR1 to the id and not SEATSOCC. Hope that its the reason behind your problem.

Regards,

Uday

matt
Active Contributor
0 Kudos

>

> I get this message

>

>

>

>

Access to 'NULL' Object reference not possible. 
> The error occured on application server apslidl_ESR_00 and in Work process 0. 
> The error message was: RABAX_STATE 
> The ABAP call hierarchy was:
> Method: WDDOINIT of program /1BCWDY/4DNCYB5TU51WEPL8ZD9X==CP
> Method: IF_WDR_VIEW_DELEGATE~WD_DO_INIT of program /1BCWDY/4DNCYB5TU51WEPL8ZD9X==CP
> Method: DO_INIT of program CL_WDR_DELEGATING_VIEW========CP
> Method: INIT_CONTROLLER of program CL_WDR_CONTROLLER=============CP
> Method: INIT_CONTROLLER of program CL_WDR_VIEW===================CP
> Method: INIT of program CL_WDR_CONTROLLER=============CP
> Method: GET_VIEW of program CL_WDR_VIEW_MANAGER===========CP
> Method: BIND_ROOT of program CL_WDR_VIEW_MANAGER===========CP
> Method: INIT of program CL_WDR_VIEW_MANAGER===========CP
> Method: INIT_CONTROLLER of program CL_WDR_INTERFACE_VIEW=========CP

Well - if my translation doesn't make it clear, I don't know what will!

Also, check ST22 to find out WHERE the error occured precisely.

matt

Answers (2)

Answers (2)

uday_gubbala2
Active Contributor
0 Kudos

Hi Sas,

If you want to be changing the position of your fields in the ALV programmatic ally then you you need to proceed as follows.

1) First get the column reference of the field whose position you want to change using the GET_COLUMN method of IF_SALV_WD_COLUMN_SETTINGS.

2) Then you can change the position of the column using the SET_POSITION method of CL_SALV_WD_COLUMN.

By default all columns have position set to 0. Columns are added u2018left justifiedu2019 to the table. This means that you can change the position of just one column without the need to explicitly set the position of all columns. Check the code fragment shown below:

method WDDOINIT .
  DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.

" Create component usage for alv component
  lo_cmp_usage =   wd_this->wd_cpuse_alv( ).
  IF lo_cmp_usage->has_active_component( ) IS INITIAL.
    lo_cmp_usage->create_component( ).
  ENDIF.

" get the ALV configuration model

  DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .
  lo_interfacecontroller =   wd_this->wd_cpifc_alv( ).

    DATA lo_value TYPE REF TO cl_salv_wd_config_table.
    lo_value = lo_interfacecontroller->get_model( ).

  data: lr_column type ref to CL_SALV_WD_COLUMN.
   DATA: ls_column TYPE salv_wd_s_column_ref.

" Get reference to desired column
   lr_column = lo_value->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( id = 'SEATSOCC' ).

   ls_column-r_column = lr_column.
" Set this column to appear as 3rd column field in the ALV output
   ls_column-r_column->set_position( 3 ).
endmethod.

Regards,

Uday

uday_gubbala2
Active Contributor
0 Kudos

Hi Sas,

The simplest way would be to change the order of the fields in the context node that you have used to bind to the DATA node of your ALV Interface controller.

You would be presently having your fields in the context node in the order shown below:

USERID 
PLANT  
MATKL 
PREIS

Just change it to: 
 
MATKL
PREIS
USERID
PLANT

That would be the simplest way of having your ALV fields in the desired order.

Regards,

Uday