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

Data transfer from internal table to dynpro.

Former Member
0 Likes
1,273

Hi everyone.

I´m trying to import the fields of an internal table to a dynpro for them to show when the screen is called.

I´ve used the export/import statements, so I already have the internal table in the PBO, but I don´t know how to assign this values to the different dynpro components.

I've got about ten fields of a Z table declared in my dynpro, the names that I can see in the attribute tabs are like ZTABLENAME-FIELD, but when I try to do something like:

ztablename-field = wa_internaltable-field

I get an error message saying that ztablename does not exist.

Does anybody know how to refer to the dynpro components from the PBO?

Thanks a lot,

Fernando Villa.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
945

HI

Check this example

&----


*& *

&----


*& *

*& *

&----


PROGRAM ZTRANS_50572 message-id zz .

*Tables.

tables: vbak, knvv.

*Declaration of variables

data: v_kunnr type kna1-kunnr,

v_vkorg type knvv-vkorg,

v_vtweg type knvv-vtweg,

v_spart type knvv-spart,

okcode like sy-ucomm,

v_dynnr like sy-dynnr,

sel type c.

*Declaration of Internal tables for transactions.

data: begin of it_knvv occurs 0,

kunnr like kna1-kunnr,

vkorg like knvv-vkorg,

vtweg like knvv-vtweg,

spart like knvv-spart,

end of it_knvv.

data: begin of it_vbak occurs 0,

vbeln like vbak-vbeln,

erdat like vbak-erdat,

ernam like vbak-ernam,

audat like vbak-audat,

auart like vbak-auart,

bstnk like vbak-bstnk,

bstdk like vbak-bstdk,

kalsm like vbak-kalsm,

kokrs like vbak-kokrs,

bukrs_vf like vbak-bukrs_vf,

chk type c,

end of it_vbak.

*CONTROL STATEMENT FOR THE TABLE CONTROL.

controls tc type tableview using screen 0300.

&----


*& Module STATUS_0100 OUTPUT

&----


  • Setting the PF status for the screen

----


module STATUS_0100 output.

SET PF-STATUS 'FF'.

  • SET TITLEBAR 'xxx'.

endmodule. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


module USER_COMMAND_0100 input.

*Validating customer no whether present in table kna1.

SELECT KUNNR INTO V_KUNNR FROM KNA1 WHERE KUNNR = V_KUNNR.

IF SY-SUBRC <> 0.

MESSAGE E000(ZZ) with 'Invalid Customer'.

endif.

endselect.

*When it is in display mode it will show in display mode else

*show it in change mode

case sy-ucomm.

when 'DISPLAY' or 'CHANGE'.

IF V_KUNNR IS NOT INITIAL.

v_dynnr = 300.

*selecting data from the table vbak into internal table.

select vbeln

erdat

ernam

audat

auart

bstnk

bstdk

kalsm

kokrs

bukrs_vf into table it_vbak

from vbak.

move sy-ucomm to okcode.

leave to screen 0200.

endif.

when 'BACK'.

leave program.

when 'EXIT'.

LEAVE TO SCREEN 0.

WHEN 'CANCEL'.

LEAVE TO SCREEN 0.

endcase.

endmodule. " USER_COMMAND_0100 INPUT

&----


*& Module STATUS_0200 OUTPUT

&----


  • text

----


module STATUS_0200 output.

SET PF-STATUS 'SS'.

  • SET TITLEBAR 'xxx'.

endmodule. " STATUS_0200 OUTPUT

&----


*& Module USER_COMMAND_0200 INPUT

&----


  • text

----


module USER_COMMAND_0200 input.

case sy-ucomm.

when 'BACK'.

leave to screen 100.

when 'EXIT'.

leave to screen 0.

when 'CANCEL'.

leave to screen 0.

endcase.

endmodule. " USER_COMMAND_0200 INPUT

&----


*& Module STATUS_0300 OUTPUT

&----


  • text

----


module STATUS_0300 output.

  • SET PF-STATUS 'xxxxxxxx'.

  • SET TITLEBAR 'xxx'.

endmodule. " STATUS_0300 OUTPUT

&----


*& Module USER_COMMAND_0300 INPUT

&----


  • text

----


module USER_COMMAND_0300 input.

case sy-ucomm.

when 'DISPLAY'.

IF V_DYNNR = 300.

LOOP AT SCREEN.

SCREEN-INPUT = 0.

MODIFY SCREEN.

ENDLOOP.

ELSE.

LOOP AT SCREEN.

SCREEN-INPUT = 1.

MODIFY SCREEN.

ENDLOOP.

ENDIF.

endcase.

endmodule. " USER_COMMAND_0300 INPUT

&----


*& Module MOD2 INPUT

&----


  • text

----


module MOD2 input.

*Validating sales organization.

SELECT VKORG INTO V_VKORG FROM TVKO WHERE VKORG = V_VKORG.

IF SY-SUBRC <> 0.

MESSAGE E000(ZZ) WITH 'Invalid Sales organization'.

endif.

endselect.

endmodule. " MOD2 INPUT

&----


*& Module MOD3 INPUT

&----


  • text

----


module MOD3 input.

*Validating distribution channel.

SELECT VTWEG INTO V_VTWEG FROM TVTW WHERE VTWEG = V_VTWEG.

IF SY-SUBRC <> 0.

MESSAGE E000(ZZ) WITH 'Invalid distribution channel'.

endif.

endselect.

endmodule. " MOD3 INPUT

&----


*& Module MOD4 INPUT

&----


  • text

----


module MOD4 input.

*Validating division.

SELECT SPART INTO V_SPART FROM TVTA WHERE SPART = V_SPART.

IF SY-SUBRC <> 0.

MESSAGE E000(ZZ) WITH 'Invalid division'.

endif.

endselect.

endmodule. " MOD4 INPUT

Regards

Laxmi

Hi everyone.

I´m trying to import the fields of an internal table to a dynpro for them to show when the screen is called.

I´ve used the export/import statements, so I already have the internal table in the PBO, but I don´t know how to assign this values to the different dynpro components.

I've got about ten fields of a Z table declared in my dynpro, the names that I can see in the attribute tabs are like ZTABLENAME-FIELD, but when I try to do something like:

ztablename-field = wa_internaltable-field

I get an error message saying that ztablename does not exist.

Does anybody know how to refer to the dynpro components from the PBO?

Thanks a lot,

Fernando Villa.

3 REPLIES 3
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
945

You should use the table control wizard within screen painter, it will walk you thru the steps of creating a table control in your screen based on the internal table definition.

Regards,

RIch Heilman

Read only

Former Member
0 Likes
945

check the table control name and use that name to pass the data.

Read only

Former Member
0 Likes
946

HI

Check this example

&----


*& *

&----


*& *

*& *

&----


PROGRAM ZTRANS_50572 message-id zz .

*Tables.

tables: vbak, knvv.

*Declaration of variables

data: v_kunnr type kna1-kunnr,

v_vkorg type knvv-vkorg,

v_vtweg type knvv-vtweg,

v_spart type knvv-spart,

okcode like sy-ucomm,

v_dynnr like sy-dynnr,

sel type c.

*Declaration of Internal tables for transactions.

data: begin of it_knvv occurs 0,

kunnr like kna1-kunnr,

vkorg like knvv-vkorg,

vtweg like knvv-vtweg,

spart like knvv-spart,

end of it_knvv.

data: begin of it_vbak occurs 0,

vbeln like vbak-vbeln,

erdat like vbak-erdat,

ernam like vbak-ernam,

audat like vbak-audat,

auart like vbak-auart,

bstnk like vbak-bstnk,

bstdk like vbak-bstdk,

kalsm like vbak-kalsm,

kokrs like vbak-kokrs,

bukrs_vf like vbak-bukrs_vf,

chk type c,

end of it_vbak.

*CONTROL STATEMENT FOR THE TABLE CONTROL.

controls tc type tableview using screen 0300.

&----


*& Module STATUS_0100 OUTPUT

&----


  • Setting the PF status for the screen

----


module STATUS_0100 output.

SET PF-STATUS 'FF'.

  • SET TITLEBAR 'xxx'.

endmodule. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


module USER_COMMAND_0100 input.

*Validating customer no whether present in table kna1.

SELECT KUNNR INTO V_KUNNR FROM KNA1 WHERE KUNNR = V_KUNNR.

IF SY-SUBRC <> 0.

MESSAGE E000(ZZ) with 'Invalid Customer'.

endif.

endselect.

*When it is in display mode it will show in display mode else

*show it in change mode

case sy-ucomm.

when 'DISPLAY' or 'CHANGE'.

IF V_KUNNR IS NOT INITIAL.

v_dynnr = 300.

*selecting data from the table vbak into internal table.

select vbeln

erdat

ernam

audat

auart

bstnk

bstdk

kalsm

kokrs

bukrs_vf into table it_vbak

from vbak.

move sy-ucomm to okcode.

leave to screen 0200.

endif.

when 'BACK'.

leave program.

when 'EXIT'.

LEAVE TO SCREEN 0.

WHEN 'CANCEL'.

LEAVE TO SCREEN 0.

endcase.

endmodule. " USER_COMMAND_0100 INPUT

&----


*& Module STATUS_0200 OUTPUT

&----


  • text

----


module STATUS_0200 output.

SET PF-STATUS 'SS'.

  • SET TITLEBAR 'xxx'.

endmodule. " STATUS_0200 OUTPUT

&----


*& Module USER_COMMAND_0200 INPUT

&----


  • text

----


module USER_COMMAND_0200 input.

case sy-ucomm.

when 'BACK'.

leave to screen 100.

when 'EXIT'.

leave to screen 0.

when 'CANCEL'.

leave to screen 0.

endcase.

endmodule. " USER_COMMAND_0200 INPUT

&----


*& Module STATUS_0300 OUTPUT

&----


  • text

----


module STATUS_0300 output.

  • SET PF-STATUS 'xxxxxxxx'.

  • SET TITLEBAR 'xxx'.

endmodule. " STATUS_0300 OUTPUT

&----


*& Module USER_COMMAND_0300 INPUT

&----


  • text

----


module USER_COMMAND_0300 input.

case sy-ucomm.

when 'DISPLAY'.

IF V_DYNNR = 300.

LOOP AT SCREEN.

SCREEN-INPUT = 0.

MODIFY SCREEN.

ENDLOOP.

ELSE.

LOOP AT SCREEN.

SCREEN-INPUT = 1.

MODIFY SCREEN.

ENDLOOP.

ENDIF.

endcase.

endmodule. " USER_COMMAND_0300 INPUT

&----


*& Module MOD2 INPUT

&----


  • text

----


module MOD2 input.

*Validating sales organization.

SELECT VKORG INTO V_VKORG FROM TVKO WHERE VKORG = V_VKORG.

IF SY-SUBRC <> 0.

MESSAGE E000(ZZ) WITH 'Invalid Sales organization'.

endif.

endselect.

endmodule. " MOD2 INPUT

&----


*& Module MOD3 INPUT

&----


  • text

----


module MOD3 input.

*Validating distribution channel.

SELECT VTWEG INTO V_VTWEG FROM TVTW WHERE VTWEG = V_VTWEG.

IF SY-SUBRC <> 0.

MESSAGE E000(ZZ) WITH 'Invalid distribution channel'.

endif.

endselect.

endmodule. " MOD3 INPUT

&----


*& Module MOD4 INPUT

&----


  • text

----


module MOD4 input.

*Validating division.

SELECT SPART INTO V_SPART FROM TVTA WHERE SPART = V_SPART.

IF SY-SUBRC <> 0.

MESSAGE E000(ZZ) WITH 'Invalid division'.

endif.

endselect.

endmodule. " MOD4 INPUT

Regards

Laxmi