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

Select does not work

Former Member
0 Likes
1,225

Hi all,

please, can you help me? I have a script, and my first select does not work (see rows 166-170 in code attached). I don know why my output value of this select is blank.
I am selecting corrective invoices list regarding to input value iv_inv - invoice.

Thank you very much for any answer.

Dimitrij

*&---------------------------------------------------------------------*



*& Report  ZBICINVLINK

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*



REPORT  ZBICINVLINK.

TABLES: DFKKINVDOC_H, ZBICBDOCH.



type-pools: slis.                                 "ALV Deklarace

*Deklarace dat

*----------------

TYPES: BEGIN OF t_link,

  SEl
,                         "Ktere radky uzivatel vybral

  invdocno
TYPE ZBICBDOCH-invdocno,

  doctype
TYPE DFKKINVDOC_H-doctype,

  crdate
TYPE DFKKINVDOC_H-crdate,

  crtime
TYPE DFKKINVDOC_H-crtime,

  total_curr
TYPE DFKKINVDOC_H-total_curr,

  total_amt
TYPE DFKKINVDOC_H-total_amt,

  reversaldoc
TYPE DFKKINVDOC_H-reversaldoc,

END OF t_link.



DATA: it_link TYPE STANDARD TABLE OF t_link INITIAL SIZE 0,

      wa_link
TYPE t_link.



*Deklarace ALV dat

data: fieldcatalog type slis_t_fieldcat_alv with header line,

      gd_tab_group
type slis_t_sp_group_alv,

      gd_layout   
type slis_layout_alv,

      gd_repid    
like sy-repid.





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

*Start-of-selection.

SELECTION-SCREEN Begin of Block b1 With Frame Title TEXT-T01.

PARAMETERS iv_inv TYPE ZBICBDOCH-invdocno_opr.

SELECTION-SCREEN End of Block b1.



START-OF-SELECTION.



 
perform data_retrieval.

 
perform build_fieldcatalog.

 
perform build_layout.

 
perform display_alv_report.





*&---------------------------------------------------------------------*

*&      Form  BUILD_FIELDCATALOG

*&---------------------------------------------------------------------*

*       Build Fieldcatalog for ALV Report

*----------------------------------------------------------------------*

form build_fieldcatalog.



  fieldcatalog
-fieldname   = 'INVDOCNO'.

  fieldcatalog
-seltext_m   = 'Císlo fakturacniho dokladu'.

  fieldcatalog
-col_pos     = 0.

  fieldcatalog
-outputlen   = 10.

  fieldcatalog
-emphasize   = 'X'.

  fieldcatalog
-key         = 'X'.

*  fieldcatalog-do_sum      = 'X'.

*  fieldcatalog-no_zero     = 'X'.

 
append fieldcatalog to fieldcatalog.

 
clear  fieldcatalog.



  fieldcatalog
-fieldname   = 'DOCTYPE'.

  fieldcatalog
-seltext_m   = 'Druh dokladu'.

  fieldcatalog
-col_pos     = 1.

 
append fieldcatalog to fieldcatalog.

 
clear  fieldcatalog.



  fieldcatalog
-fieldname   = 'CRDATE'.

  fieldcatalog
-seltext_m   = 'Datum vytvoreni fakturacniho dokladu'.

  fieldcatalog
-col_pos     = 2.

 
append fieldcatalog to fieldcatalog.

 
clear  fieldcatalog.



  fieldcatalog
-fieldname   = 'CRTIME'.

  fieldcatalog
-seltext_m   = 'Cas vytvoreni fakturacniho dokladu'.

  fieldcatalog
-col_pos     = 3.

 
append fieldcatalog to fieldcatalog.

 
clear  fieldcatalog.



  fieldcatalog
-fieldname   = 'TOTAL_AMT'.

  fieldcatalog
-seltext_m   = 'Castka ve mene transakce se znamenkem'.

  fieldcatalog
-col_pos     = 4.

 
append fieldcatalog to fieldcatalog.

 
clear  fieldcatalog.



  fieldcatalog
-fieldname   = 'TOTAL_CURR'.

  fieldcatalog
-seltext_m   = 'Mena transakce'.

  fieldcatalog
-col_pos     = 5.

 
append fieldcatalog to fieldcatalog.

 
clear  fieldcatalog.



  fieldcatalog
-fieldname   = 'REVERSALDOC'.

  fieldcatalog
-seltext_m   = 'Cislo stornovaciho dokladu k fakturacnimu dokladu'.

  fieldcatalog
-col_pos     = 6.

 
append fieldcatalog to fieldcatalog.

 
clear  fieldcatalog.



endform.                    " BUILD_FIELDCATALOG





*&---------------------------------------------------------------------*

*&      Form  BUILD_LAYOUT

*&---------------------------------------------------------------------*

*       Build layout for ALV grid report

*----------------------------------------------------------------------*

form build_layout.

  gd_layout
-box_fieldname     = 'SEL'.

 
"set field name to store row selection

  gd_layout
-edit              = 'X'. "makes whole ALV table editable

  gd_layout
-zebra             = 'X'.

endform.                    " BUILD_LAYOUT





*&---------------------------------------------------------------------*

*&      Form  DISPLAY_ALV_REPORT

*&---------------------------------------------------------------------*

*       Display report using ALV grid

*----------------------------------------------------------------------*

form display_alv_report.

  gd_repid
= sy-repid.

 
call function 'REUSE_ALV_GRID_DISPLAY'

      
exporting

            i_callback_program     
= gd_repid

*            i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM

            i_callback_user_command
= 'USER_COMMAND'

*            i_grid_title           = outtext

            is_layout              
= gd_layout

            it_fieldcat            
= fieldcatalog[]

*            it_special_groups       = gd_tabgroup

*            IT_EVENTS                = GT_XEVENTS

            i_save                 
= 'X'

*            is_variant              = z_template



      
tables

            t_outtab               
= it_link

      
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.                    " DISPLAY_ALV_REPORT





*&---------------------------------------------------------------------*

*&      Form  DATA_RETRIEVAL

*&---------------------------------------------------------------------*

*

*----------------------------------------------------------------------*

form data_retrieval.



 
DATA: invdocno_opr TYPE ZBICBDOCH-invdocno_opr,

        iv_inv
TYPE ZBICBDOCH-invdocno_opr.



IF  iv_inv is initial.

MESSAGE s002(00) WITH 'Message'.

ENDIF.



IF  iv_inv is not initial.

 
select invdocno

   
from ZBICBDOCH

   
into corresponding fields of table it_link

   
where invdocno_opr EQ iv_inv.



 
select doctype crdate crtime total_curr total_amt reversaldoc

   
from DFKKINVDOC_H

   
into corresponding fields of table it_link.

   
ENDIF.

endform.                    " DATA_RETRIEVAL





*------------------------------------------------------------------*

*       FORM USER_COMMAND                                          *

*------------------------------------------------------------------*

*       --> R_UCOMM                                                *

*       --> RS_SELFIELD                                            *

*------------------------------------------------------------------*

FORM user_command USING r_ucomm LIKE sy-ucomm

                  rs_selfield
TYPE slis_selfield.



* Kontrola funkcniho kodu

 
CASE r_ucomm.

   
WHEN '&IC1'.

*   Kontrola poli ALV reportu

     
IF rs_selfield-fieldname = 'INVDOCNO'.

*     Nacteni tabulky dat pomocí indexu radku, na ktery uživatel klikl

       
READ TABLE it_link INTO wa_link INDEX rs_selfield-tabindex.

*     Nastavi parametr ID pro oblast obrazovky transakci

       
SET PARAMETER ID 'BES' FIELD wa_link-invdocno.

*     Zavola transakci ME23N a prejde na uvodni obrazovku pro zadavani dat

       
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.

     
ENDIF.



   
WHEN '&DATA_SAVE'"uzovatel zmackne ULOZIT

     
loop at it_link into wa_link.

       
if wa_link-sel EQ 'X'.

*       Zpracuje zaznamy, ktere byly vybrany

       
endif.

     
endloop.

 
ENDCASE.

ENDFORM.                    "user_command

1 ACCEPTED SOLUTION
Read only

former_member209120
Active Contributor
0 Likes
1,151

Hi Dimitrij Jurcenko,


Simple

REPORT  ZBICINVLINK.

TABLES: DFKKINVDOC_H, ZBICBDOCH.


type-pools: slis.                                 "ALV Deklarace

*Deklarace dat

*----------------

TYPES: BEGIN OF t_link,

  SEl
,                         "Ktere radky uzivatel vybral

  invdocno
TYPE ZBICBDOCH-invdocno,

  doctype
TYPE DFKKINVDOC_H-doctype,

  crdate
TYPE DFKKINVDOC_H-crdate,

  crtime
TYPE DFKKINVDOC_H-crtime,

  total_curr
TYPE DFKKINVDOC_H-total_curr,

  total_amt
TYPE DFKKINVDOC_H-total_amt,

  reversaldoc
TYPE DFKKINVDOC_H-reversaldoc,

END OF t_link.



DATA: it_link TYPE STANDARD TABLE OF t_link INITIAL SIZE 0,

      wa_link
TYPE t_link.



*Deklarace ALV dat

data: fieldcatalog type slis_t_fieldcat_alv with header line,

      gd_tab_group
type slis_t_sp_group_alv,

      gd_layout   
type slis_layout_alv,

      gd_repid    
like sy-repid.





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

*Start-of-selection.

SELECTION-SCREEN Begin of Block b1 With Frame Title TEXT-T01.

PARAMETERS iv_inv TYPE ZBICBDOCH-invdocno_opr.

SELECTION-SCREEN End of Block b1.



START-OF-SELECTION.



 
perform data_retrieval.

 
perform build_fieldcatalog.

 
perform build_layout.

 
perform display_alv_report.





*&---------------------------------------------------------------------*

*&      Form  BUILD_FIELDCATALOG

*&---------------------------------------------------------------------*

*       Build Fieldcatalog for ALV Report

*----------------------------------------------------------------------*

form build_fieldcatalog.



  fieldcatalog
-fieldname   = 'INVDOCNO'.

  fieldcatalog
-seltext_m   = 'Císlo fakturacniho dokladu'.

  fieldcatalog
-col_pos     = 0.

  fieldcatalog
-outputlen   = 10.

  fieldcatalog
-emphasize   = 'X'.

  fieldcatalog
-key         = 'X'.

*  fieldcatalog-do_sum      = 'X'.

*  fieldcatalog-no_zero     = 'X'.

 
append fieldcatalog to fieldcatalog.

 
clear  fieldcatalog.



  fieldcatalog
-fieldname   = 'DOCTYPE'.

  fieldcatalog
-seltext_m   = 'Druh dokladu'.

  fieldcatalog
-col_pos     = 1.

 
append fieldcatalog to fieldcatalog.

 
clear  fieldcatalog.



  fieldcatalog
-fieldname   = 'CRDATE'.

  fieldcatalog
-seltext_m   = 'Datum vytvoreni fakturacniho dokladu'.

  fieldcatalog
-col_pos     = 2.

 
append fieldcatalog to fieldcatalog.

 
clear  fieldcatalog.



  fieldcatalog
-fieldname   = 'CRTIME'.

  fieldcatalog
-seltext_m   = 'Cas vytvoreni fakturacniho dokladu'.

  fieldcatalog
-col_pos     = 3.

 
append fieldcatalog to fieldcatalog.

 
clear  fieldcatalog.



  fieldcatalog
-fieldname   = 'TOTAL_AMT'.

  fieldcatalog
-seltext_m   = 'Castka ve mene transakce se znamenkem'.

  fieldcatalog
-col_pos     = 4.

 
append fieldcatalog to fieldcatalog.

 
clear  fieldcatalog.



  fieldcatalog
-fieldname   = 'TOTAL_CURR'.

  fieldcatalog
-seltext_m   = 'Mena transakce'.

  fieldcatalog
-col_pos     = 5.

 
append fieldcatalog to fieldcatalog.

 
clear  fieldcatalog.



  fieldcatalog
-fieldname   = 'REVERSALDOC'.

  fieldcatalog
-seltext_m   = 'Cislo stornovaciho dokladu k fakturacnimu dokladu'.

  fieldcatalog
-col_pos     = 6.

 
append fieldcatalog to fieldcatalog.

 
clear  fieldcatalog.



endform.                    " BUILD_FIELDCATALOG





*&---------------------------------------------------------------------*

*&      Form  BUILD_LAYOUT

*&---------------------------------------------------------------------*

*       Build layout for ALV grid report

*----------------------------------------------------------------------*

form build_layout.

  gd_layout
-box_fieldname     = 'SEL'.

 
"set field name to store row selection

  gd_layout
-edit              = 'X'. "makes whole ALV table editable

  gd_layout
-zebra             = 'X'.

endform.                    " BUILD_LAYOUT





*&---------------------------------------------------------------------*

*&      Form  DISPLAY_ALV_REPORT

*&---------------------------------------------------------------------*

*       Display report using ALV grid

*----------------------------------------------------------------------*

form display_alv_report.

  gd_repid
= sy-repid.

 
call function 'REUSE_ALV_GRID_DISPLAY'

      
exporting

            i_callback_program     
= gd_repid

*            i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM

            i_callback_user_command
= 'USER_COMMAND'

*            i_grid_title           = outtext

            is_layout              
= gd_layout

            it_fieldcat            
= fieldcatalog[]

*            it_special_groups       = gd_tabgroup

*            IT_EVENTS                = GT_XEVENTS

            i_save                 
= 'X'

*            is_variant              = z_template



      
tables

            t_outtab               
= it_link

      
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.                    " DISPLAY_ALV_REPORT





*&---------------------------------------------------------------------*

*&      Form  DATA_RETRIEVAL

*&---------------------------------------------------------------------*

*

*----------------------------------------------------------------------*

form data_retrieval.



 
DATA: invdocno_opr TYPE ZBICBDOCH-invdocno_opr,

        iv_inv
TYPE ZBICBDOCH-invdocno_opr.                         " Remove this Two times declared in parameter and here



IF  iv_inv is initial.

MESSAGE s002(00) WITH 'Message'.

ENDIF.



IF  iv_inv is not initial.

 
select invdocno

   
from ZBICBDOCH

   
into corresponding fields of table it_link

   
where invdocno_opr EQ iv_inv.



 
select doctype crdate crtime total_curr total_amt reversaldoc

   
from DFKKINVDOC_H

   
into corresponding fields of table it_link.                                        " Where statement not used here


   
ENDIF.

endform.                    " DATA_RETRIEVAL





*------------------------------------------------------------------*

*       FORM USER_COMMAND                                          *

*------------------------------------------------------------------*

*       --> R_UCOMM                                                *

*       --> RS_SELFIELD                                            *

*------------------------------------------------------------------*

FORM user_command USING r_ucomm LIKE sy-ucomm

                  rs_selfield
TYPE slis_selfield.



* Kontrola funkcniho kodu

 
CASE r_ucomm.

   
WHEN '&IC1'.

*   Kontrola poli ALV reportu

     
IF rs_selfield-fieldname = 'INVDOCNO'.

*     Nacteni tabulky dat pomocí indexu radku, na ktery uživatel klikl

       
READ TABLE it_link INTO wa_link INDEX rs_selfield-tabindex.

*     Nastavi parametr ID pro oblast obrazovky transakci

       
SET PARAMETER ID 'BES' FIELD wa_link-invdocno.

*     Zavola transakci ME23N a prejde na uvodni obrazovku pro zadavani dat

       
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.

     
ENDIF.



   
WHEN '&DATA_SAVE'"uzovatel zmackne ULOZIT

     
loop at it_link into wa_link.

       
if wa_link-sel EQ 'X'.

*       Zpracuje zaznamy, ktere byly vybrany

       
endif.

     
endloop.

 
ENDCASE.

ENDFORM.                    "user_command

7 REPLIES 7
Read only

PeterJonker
Active Contributor
0 Likes
1,151

Did you check in debug what the value is of iv_inv ? Maybe it needs leading zeroes ?

Is your first select returning values ?

If yes what happens with the internal table if your program executes the 2nd select ?

Your second select does not have a where clause so it should select al entries in the table.

Read only

Former Member
0 Likes
1,151

Hi Dimitrij,

You are using ZBICBDOCH-invdocno_opr this as your parameter's associated data type and fetching the data from same table.So go to domain of the same and see which conversion routine is there. Suppose your conversion routine is XXXX, then call following FM before executiong select statement :

Call Function 'CONVERSION_EXIT_XXXX_INPUT'

        INPUT      = iv_inv

      OUTPUT     = iv_inv.

It will correct your value in parameter.

Regards,

Dipesh

Read only

Former Member
0 Likes
1,151

Check the value of in_inv as Peter said.

And with regards to the function module if you need to add leading zeroes, it is,

CONVERSION_EXIT_ALPHA_INPUT.

Another theory would be that the data type of ZBICBDOCH-invdocno_opr is integer. So even though you input a number with leading zeroes, the leading zeroes will be removed. A work around would be to move in_inv to a variable with a numc data type.

Regards,

Christian

Read only

Former Member
0 Likes
1,151

hi Dimitrij,

In addition. why you have two in_inv? one is selection parameter, another is partial variable in your retrieval form. this is not good to code readability.

regards,

Archer.

Read only

former_member209120
Active Contributor
0 Likes
1,152

Hi Dimitrij Jurcenko,


Simple

REPORT  ZBICINVLINK.

TABLES: DFKKINVDOC_H, ZBICBDOCH.


type-pools: slis.                                 "ALV Deklarace

*Deklarace dat

*----------------

TYPES: BEGIN OF t_link,

  SEl
,                         "Ktere radky uzivatel vybral

  invdocno
TYPE ZBICBDOCH-invdocno,

  doctype
TYPE DFKKINVDOC_H-doctype,

  crdate
TYPE DFKKINVDOC_H-crdate,

  crtime
TYPE DFKKINVDOC_H-crtime,

  total_curr
TYPE DFKKINVDOC_H-total_curr,

  total_amt
TYPE DFKKINVDOC_H-total_amt,

  reversaldoc
TYPE DFKKINVDOC_H-reversaldoc,

END OF t_link.



DATA: it_link TYPE STANDARD TABLE OF t_link INITIAL SIZE 0,

      wa_link
TYPE t_link.



*Deklarace ALV dat

data: fieldcatalog type slis_t_fieldcat_alv with header line,

      gd_tab_group
type slis_t_sp_group_alv,

      gd_layout   
type slis_layout_alv,

      gd_repid    
like sy-repid.





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

*Start-of-selection.

SELECTION-SCREEN Begin of Block b1 With Frame Title TEXT-T01.

PARAMETERS iv_inv TYPE ZBICBDOCH-invdocno_opr.

SELECTION-SCREEN End of Block b1.



START-OF-SELECTION.



 
perform data_retrieval.

 
perform build_fieldcatalog.

 
perform build_layout.

 
perform display_alv_report.





*&---------------------------------------------------------------------*

*&      Form  BUILD_FIELDCATALOG

*&---------------------------------------------------------------------*

*       Build Fieldcatalog for ALV Report

*----------------------------------------------------------------------*

form build_fieldcatalog.



  fieldcatalog
-fieldname   = 'INVDOCNO'.

  fieldcatalog
-seltext_m   = 'Císlo fakturacniho dokladu'.

  fieldcatalog
-col_pos     = 0.

  fieldcatalog
-outputlen   = 10.

  fieldcatalog
-emphasize   = 'X'.

  fieldcatalog
-key         = 'X'.

*  fieldcatalog-do_sum      = 'X'.

*  fieldcatalog-no_zero     = 'X'.

 
append fieldcatalog to fieldcatalog.

 
clear  fieldcatalog.



  fieldcatalog
-fieldname   = 'DOCTYPE'.

  fieldcatalog
-seltext_m   = 'Druh dokladu'.

  fieldcatalog
-col_pos     = 1.

 
append fieldcatalog to fieldcatalog.

 
clear  fieldcatalog.



  fieldcatalog
-fieldname   = 'CRDATE'.

  fieldcatalog
-seltext_m   = 'Datum vytvoreni fakturacniho dokladu'.

  fieldcatalog
-col_pos     = 2.

 
append fieldcatalog to fieldcatalog.

 
clear  fieldcatalog.



  fieldcatalog
-fieldname   = 'CRTIME'.

  fieldcatalog
-seltext_m   = 'Cas vytvoreni fakturacniho dokladu'.

  fieldcatalog
-col_pos     = 3.

 
append fieldcatalog to fieldcatalog.

 
clear  fieldcatalog.



  fieldcatalog
-fieldname   = 'TOTAL_AMT'.

  fieldcatalog
-seltext_m   = 'Castka ve mene transakce se znamenkem'.

  fieldcatalog
-col_pos     = 4.

 
append fieldcatalog to fieldcatalog.

 
clear  fieldcatalog.



  fieldcatalog
-fieldname   = 'TOTAL_CURR'.

  fieldcatalog
-seltext_m   = 'Mena transakce'.

  fieldcatalog
-col_pos     = 5.

 
append fieldcatalog to fieldcatalog.

 
clear  fieldcatalog.



  fieldcatalog
-fieldname   = 'REVERSALDOC'.

  fieldcatalog
-seltext_m   = 'Cislo stornovaciho dokladu k fakturacnimu dokladu'.

  fieldcatalog
-col_pos     = 6.

 
append fieldcatalog to fieldcatalog.

 
clear  fieldcatalog.



endform.                    " BUILD_FIELDCATALOG





*&---------------------------------------------------------------------*

*&      Form  BUILD_LAYOUT

*&---------------------------------------------------------------------*

*       Build layout for ALV grid report

*----------------------------------------------------------------------*

form build_layout.

  gd_layout
-box_fieldname     = 'SEL'.

 
"set field name to store row selection

  gd_layout
-edit              = 'X'. "makes whole ALV table editable

  gd_layout
-zebra             = 'X'.

endform.                    " BUILD_LAYOUT





*&---------------------------------------------------------------------*

*&      Form  DISPLAY_ALV_REPORT

*&---------------------------------------------------------------------*

*       Display report using ALV grid

*----------------------------------------------------------------------*

form display_alv_report.

  gd_repid
= sy-repid.

 
call function 'REUSE_ALV_GRID_DISPLAY'

      
exporting

            i_callback_program     
= gd_repid

*            i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM

            i_callback_user_command
= 'USER_COMMAND'

*            i_grid_title           = outtext

            is_layout              
= gd_layout

            it_fieldcat            
= fieldcatalog[]

*            it_special_groups       = gd_tabgroup

*            IT_EVENTS                = GT_XEVENTS

            i_save                 
= 'X'

*            is_variant              = z_template



      
tables

            t_outtab               
= it_link

      
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.                    " DISPLAY_ALV_REPORT





*&---------------------------------------------------------------------*

*&      Form  DATA_RETRIEVAL

*&---------------------------------------------------------------------*

*

*----------------------------------------------------------------------*

form data_retrieval.



 
DATA: invdocno_opr TYPE ZBICBDOCH-invdocno_opr,

        iv_inv
TYPE ZBICBDOCH-invdocno_opr.                         " Remove this Two times declared in parameter and here



IF  iv_inv is initial.

MESSAGE s002(00) WITH 'Message'.

ENDIF.



IF  iv_inv is not initial.

 
select invdocno

   
from ZBICBDOCH

   
into corresponding fields of table it_link

   
where invdocno_opr EQ iv_inv.



 
select doctype crdate crtime total_curr total_amt reversaldoc

   
from DFKKINVDOC_H

   
into corresponding fields of table it_link.                                        " Where statement not used here


   
ENDIF.

endform.                    " DATA_RETRIEVAL





*------------------------------------------------------------------*

*       FORM USER_COMMAND                                          *

*------------------------------------------------------------------*

*       --> R_UCOMM                                                *

*       --> RS_SELFIELD                                            *

*------------------------------------------------------------------*

FORM user_command USING r_ucomm LIKE sy-ucomm

                  rs_selfield
TYPE slis_selfield.



* Kontrola funkcniho kodu

 
CASE r_ucomm.

   
WHEN '&IC1'.

*   Kontrola poli ALV reportu

     
IF rs_selfield-fieldname = 'INVDOCNO'.

*     Nacteni tabulky dat pomocí indexu radku, na ktery uživatel klikl

       
READ TABLE it_link INTO wa_link INDEX rs_selfield-tabindex.

*     Nastavi parametr ID pro oblast obrazovky transakci

       
SET PARAMETER ID 'BES' FIELD wa_link-invdocno.

*     Zavola transakci ME23N a prejde na uvodni obrazovku pro zadavani dat

       
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.

     
ENDIF.



   
WHEN '&DATA_SAVE'"uzovatel zmackne ULOZIT

     
loop at it_link into wa_link.

       
if wa_link-sel EQ 'X'.

*       Zpracuje zaznamy, ktere byly vybrany

       
endif.

     
endloop.

 
ENDCASE.

ENDFORM.                    "user_command

Read only

Former Member
0 Likes
1,151

Hi Dimit

for the validation of parameter iv_inv , use event

At Selection screen.

if  iv_inv is initial.

     message 'Enter the value' type '!'.

else.

     select single count(*)

       from ZBICBDOCH

      where invdocno_opr eq iv_inv.

     if sy-subrc <> 0.

          message 'No records exist' type 'E'.

     endif.

endif.

And for ur populating internal table

if it_link is initial.
 
select invdocno

   
from ZBICBDOCH

   
into corresponding fields of table it_link

   
where invdocno_opr EQ iv_inv.

     if sy-subrc <> 0.

          message 'Databse fetch failed' type 'E'.

          stop.

     endif.    



 
select doctype crdate crtime total_curr total_amt reversaldoc

   
from DFKKINVDOC_H

   
into corresponding fields of table it_link

     where invdocno_opr EQ iv_inv.

     check sy-subrc.

                                     

   
ENDIF.

Debug the code and check the sy-subrc value after data base check of first select statment and also internal table contents.

Read only

Former Member
0 Likes
1,151

Hi guys,

thank you very much for all your answers, there were very helpful!

I have corrected my code by update below and it is work fine now!

Best Regards,
Dimitrij

IF

iv_inv is not initial.

 
select SINGLE * "vybiram si radek s puvodni fakturou a jejimi detaily

 
from DFKKINVDOC_H into CORRESPONDING FIELDS OF it_link

 
where invdocno EQ iv_inv.



check sy-subrc is INITIAL.

APPEND it_link.



   
select * "vybiram si opravne doklady

     
from ZBICBDOCH

     
where invdocno_opr EQ iv_inv.

     
clear it_link.

     
MOVE-CORRESPONDING ZBICBDOCH to it_link.

     
APPEND it_link.

     
endselect.



    
select * "vybiram si detaily k opravnym dokladum vybranym v predchozim selectu

      
from DFKKINVDOC_H into CORRESPONDING FIELDS OF TABLE it_link

      
FOR ALL ENTRIES IN it_link

      
where invdocno EQ it_link-invdocno.

      
clear it_link.

      
MOVE-CORRESPONDING DFKKINVDOC_H to it_link.

      
ENDIF.