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

CHAR23

Former Member
0 Likes
1,083

Good Day ...

My app dynamically creates a DDIC Table.

Because I have no idea of what field lengths will be for CHAR types until runtime, I query DD01L for type = CHAR leng = n. If the query fails I increment n and query till a result is returned.

This method appears to work until CHAR(23). I find this odd as there is an entry in DD01L for type CHAR LENG 23.

anyone have any thoughts ??

THANKS !!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,031

Hello David,

You are looking at the domain table DD01L. Your selection provides you with 12 different domains. One of them is CHAR23. And you are constructing a line like

data: a type CHAR23.

CHAR23 has to be a Data Element!

And the correlation between Domain and Data Element can be viewed in table DD04L. In this table you will find that none of the previously selected 12 domains does have a data element CHAR23. Unfortunately all other domains do have an appropriate Data Element; CHAR22, CHAR21, CHAR20,.....CHAR2, CHAR1. CHAR24, CHAR25 ..... exists again.

Result:

CHAR23 is missing in the Data element table DD04L.

You have to build in a different check, i.e. a modification of the FM z_check_datatype is required. Instead of DD01L, DD04L should be used.

Hope this helps,

Heinz

Hello David,

You are looking at the domain table DD01L. Your selection provides you with 12 different domains. One of them is CHAR23. And you are constructing a line like

data: a type CHAR23.

CHAR23 has to be a Data Element!

And the correlation between Domain and Data Element can be viewed in table DD04L. In this table you will find that none of the previously selected 12 domains does have a data element CHAR23. Unfortunately all other domains do have an appropriate Data Element; CHAR22, CHAR21, CHAR20,.....CHAR2, CHAR1. CHAR24, CHAR25 ..... exists again.

Result:

CHAR23 is missing in the Data element table DD04L.

You have to build in a different check, i.e. a modification of the FM z_check_datatype is required. Instead of DD01L, DD04L should be used.

Hope this helps,

Heinz

6 REPLIES 6
Read only

Former Member
0 Likes
1,031

Could you post the routine to select the domain?

Read only

0 Likes
1,031

function z_create_tabl .

*"----


""Local Interface:

*" IMPORTING

*" VALUE(ROWS) TYPE INTEGER DEFAULT 1

*" VALUE(COLS) TYPE INTEGER DEFAULT 4

*" VALUE(NAME) TYPE CHAR30 DEFAULT 'ZDBC'

*" VALUE(FIELD_NAMES) TYPE CHAR1024 DEFAULT 'A|B|C|D'

*" VALUE(COL_WIDTH) TYPE CHAR1024 DEFAULT '4|135|4|4'

*" VALUE(DATA_TYPE) TYPE CHAR1024 DEFAULT 'I|C|I|C'

*" VALUE(USER) TYPE CHAR30 DEFAULT 'BRENCHLEY'

*" EXPORTING

*" VALUE(SAP_MESSAGE) TYPE CHAR1024

*" VALUE(COLS1) TYPE INTEGER

*" VALUE(DELIM1) TYPE CHAR1

*" VALUE(FIELD_NAMES1) TYPE CHAR1024

*" VALUE(TABNAME) TYPE CHAR30

*" VALUE(USER1) TYPE CHAR30

*" VALUE(DATA_TYPE1) TYPE CHAR1024

*" VALUE(COL_WIDTH1) TYPE CHAR1024

*"----


data f_cnt type integer.

data f_name type char15.

data f_type type char2.

data f_width type char3.

data f_width2 type i.

data mem_area type char30.

data delim type c value '|'.

data repname type char30.

data tmp type char72.

data: fm type char24.

data: f_dat type char1024.

data: code type table of rssource-line.

data: result type bool value 'N'.

cols1 = cols.

delim1 = delim.

field_names1 = field_names.

tabname = name.

user1 = user.

data_type1 = data_type.

col_width1 = col_width.

concatenate user 'B' into tmp.

export delim1 to memory id tmp.

concatenate user 'C' into tmp.

export cols1 to memory id tmp.

concatenate user 'D' into tmp.

export field_names1 to memory id tmp.

concatenate user 'E' into tmp.

export tabname to memory id tmp.

concatenate user 'F' into tmp.

export user1 to memory id tmp.

concatenate user 'G' into tmp.

export data_type1 to memory id tmp.

concatenate user 'H' into tmp.

export col_width1 to memory id tmp.

concatenate '''' name '''' into tabname.

concatenate 'Z_BLD_STRUC_' user into repname.

concatenate 'REPORT' repname '.' into tmp separated by space.

append tmp to code.

append 'TYPES: BEGIN OF mySTRUC,' to code.

f_cnt = cols.

while f_cnt > 0.

split field_names at delim into f_name field_names.

split data_type at delim into f_type data_type.

split col_width at delim into f_width col_width.

if f_type = 'C'.

move f_width to f_width2.

while result = 'N'.

call function 'Z_CHECK_DATATYPE' " Check DD01L for CHAR of Length

exporting char_length = f_width2

importing result = result.

if result = 'N'.

f_width = f_width + 1. "Adjust Field Width to suit DD01L

move f_width to f_width2.

endif.

endwhile.

f_type = ' C'.

concatenate f_name'(' f_width') TYPE' f_type',' into tmp.

append tmp to code.

else.

if f_type = 'P'.

concatenate f_name 'TYPE' f_type 'DECIMALS 2,' into tmp separated by space.

append tmp to code.

else.

concatenate f_name 'TYPE' f_type ',' into tmp separated by space.

append tmp to code.

endif.

endif.

f_cnt = f_cnt - 1.

endwhile.

append 'END OF mySTRUC.' to code.

append 'FIELD-SYMBOLS:' to code.

append '<theStruc> TYPE ANY,' to code.

append '<theField> TYPE ANY.' to code.

append 'DATA: DELIM1 TYPE CHAR1.' to code.

append 'DATA: FIELD_NAMES1 TYPE CHAR1024.' to code.

append 'DATA: DATA_TYPE1 TYPE CHAR1024.' to code.

append 'DATA: COL_WIDTH1 TYPE CHAR1024.' to code.

append 'DATA: COLS1 TYPE INTEGER.' to code.

append 'DATA: TABLINE TYPE myStruc.' to code.

append 'DATA: F_DAT TYPE CHAR1024.' to code.

append 'DATA: F_NAME1 TYPE CHAR30.' to code.

append 'DATA: F_TYPE TYPE CHAR2.' to code.

append 'DATA: F_TYPE2 TYPE CHAR10.' to code.

append 'DATA: F_WIDTH TYPE CHAR4.' to code.

append 'DATA: F_WIDTH_2 TYPE INTEGER.' to code.

append 'DATA: TMP TYPE CHAR10.' to code.

append 'DATA: TABNAME TYPE CHAR30.' to code.

append 'DATA: TABDEF TYPE DD02V.' to code.

append 'DATA: TABTECH TYPE DD09L.' to code.

append 'DATA: TABFIELDS TYPE TABLE OF DD03P WITH HEADER LINE.' to code.

append 'DATA: CNTR TYPE INTEGER.' to code.

append 'DATA: USER1 TYPE CHAR30.' to code.

append 'DATA: KEY_DONE TYPE BOOL.' to code.

append 'DATA: CHAR_CNT TYPE INTEGER.' to code.

append 'DATA: CHAR_CNT_2 TYPE INTEGER.' to code.

concatenate 'DATA:' name 'TYPE STANDARD TABLE OF mySTRUC WITH HEADER LINE.' into tmp separated by space.

append tmp to code.

concatenate 'IMPORT DELIM1 FROM MEMORY ID ' '''' user 'B' '''' '.' into tmp.

append tmp to code.

concatenate 'IMPORT COLS1 FROM MEMORY ID ' '''' user 'C' '''' '.' into tmp.

append tmp to code.

concatenate 'IMPORT FIELD_NAMES1 FROM MEMORY ID ' '''' user 'D' '''' '.' into tmp.

append tmp to code.

concatenate 'IMPORT TABNAME FROM MEMORY ID ' '''' user 'E' '''' '.' into tmp.

append tmp to code.

concatenate 'IMPORT USER1 FROM MEMORY ID ' '''' user 'F' '''' '.' into tmp.

append tmp to code.

concatenate 'IMPORT DATA_TYPE1 FROM MEMORY ID ' '''' user 'G' '''' '.' into tmp.

append tmp to code.

concatenate 'IMPORT COL_WIDTH1 FROM MEMORY ID ' '''' user 'H' '''' '.' into tmp.

append tmp to code.

append 'ASSIGN TABLINE TO <theStruc>.' to code.

append 'TABDEF-TABNAME = TABNAME.' to code.

concatenate 'TABDEF-TABCLASS =' '''' 'TRANSP' '''' '.' into tmp.

append tmp to code.

append 'TABDEF-DDLANGUAGE = sy-langu.' to code.

append 'TABDEF-LANGDEP = sy-langu.' to code.

concatenate 'TABDEF-DDTEXT =' '''' 'DYNAMIC TABLE CREATED VIA RFC' '''' '.' into tmp.

append tmp to code.

concatenate 'TABDEF-CONTFLAG =' '''' 'C' '''' '.' into tmp.

append tmp to code.

append 'TABTECH-TABNAME = TABNAME.' to code.

concatenate 'TABTECH-TABART =' '''' 'APPL0' '''' '.' into tmp.

append tmp to code.

concatenate 'TABTECH-TABKAT =' '''' '6' '''' '.' into tmp.

append tmp to code.

concatenate 'TABTECH-ACTFLAG =' '''' 'X' '''' '.' into tmp.

append tmp to code.

concatenate 'KEY_DONE =' '''' 'N' '''' '.' into tmp.

append tmp to code.

append 'WHILE COLS1 > 0.' to code.

append 'CNTR = CNTR + 1.' to code.

append 'SPLIT FIELD_NAMES1 AT DELIM1 INTO F_NAME1 FIELD_NAMES1.' to code.

append 'SPLIT DATA_TYPE1 AT DELIM1 INTO F_TYPE DATA_TYPE1.' to code.

append 'SPLIT COL_WIDTH1 AT DELIM1 INTO F_WIDTH COL_WIDTH1.' to code.

append 'ASSIGN COMPONENT F_NAME1 OF STRUCTURE <theStruc> to <theField>.' to code.

append '<theField> = F_DAT.' to code.

append '"================================================' to code.

append 'CASE F_TYPE.' to code.

concatenate 'WHEN ' '''' 'C' '''' '.' into tmp.

append tmp to code.

concatenate 'CONCATENATE' ' ' '''' 'CHAR' '''' ' ' 'F_WIDTH into TMP.' into tmp.

append tmp to code.

append 'F_TYPE2 = TMP.' to code.

concatenate 'WHEN ' '''' 'I' '''' '.' into tmp.

append tmp to code.

concatenate 'F_TYPE2 = ' '''' 'INTEGER' '''' '.' into tmp.

append tmp to code.

concatenate 'WHEN ' '''' 'D' '''' '.' into tmp.

append tmp to code.

concatenate 'F_TYPE2 = ' '''' 'DATS' '''' '.' into tmp.

append tmp to code.

concatenate 'WHEN ' '''' 'T' '''' '.' into tmp.

append tmp to code.

concatenate 'F_TYPE2 = ' '''' 'TIMS' '''' '.' into tmp.

append tmp to code.

concatenate 'WHEN ' '''' 'F' '''' '.' into tmp.

append tmp to code.

concatenate 'F_TYPE2 = ' '''' 'FLOAT' '''' '.' into tmp.

append tmp to code.

concatenate 'WHEN ' '''' 'P' '''' '.' into tmp.

append tmp to code.

concatenate 'F_TYPE2 = ' '''' 'SRMCURR' '''' '.' into tmp.

append tmp to code.

append 'ENDCASE.' to code.

append '"================================================' to code.

append 'CLEAR TABFIELDS.' to code.

append 'TABFIELDS-TABNAME = TABNAME.' to code.

append 'TABFIELDS-FIELDNAME = F_NAME1.' to code.

append 'MOVE F_WIDTH TO F_WIDTH_2.' to code.

append 'CHAR_CNT = CHAR_CNT_2 + F_WIDTH_2.' to code.

concatenate 'IF KEY_DONE =' '''' 'N' '''' '.' into tmp.

append tmp to code.

append 'IF CHAR_CNT < 120.' to code.

concatenate 'TABFIELDS-KEYFLAG =' '''' 'X' '''' '.' into tmp.

append tmp to code.

append 'CHAR_CNT_2 = CHAR_CNT + F_WIDTH_2.' to code.

append 'ELSE.' to code.

concatenate 'TABFIELDS-KEYFLAG =' '''' ' ' '''' '.' into tmp.

append tmp to code.

concatenate 'KEY_DONE =' '''' 'Y' '''' '.' into tmp.

append tmp to code.

append 'ENDIF.' to code.

append 'ENDIF.' to code.

append 'TABFIELDS-ROLLNAME = F_TYPE2.' to code.

append 'TABFIELDS-POSITION = CNTR.' to code.

append 'TABFIELDS-DATATYPE = F_TYPE.' to code.

append 'TABFIELDS-LENG = F_WIDTH.' to code.

concatenate 'IF f_type =' '''' 'P' '''' '.' into tmp.

append tmp to code.

concatenate 'TABFIELDS-REFTABLE =' '''' 'TCURX' '''' '.' into tmp.

append tmp to code.

concatenate 'TABFIELDS-REFFIELD =' '''' 'CURRKEY' '''' '.' into tmp.

append tmp to code.

append 'ENDIF.' to code.

append 'APPEND TABFIELDS.' to code.

append 'COLS1 = COLS1 - 1.' to code.

append 'ENDWHILE.' to code.

concatenate 'APPEND TABLINE TO' name '.' into tmp separated by space.

append tmp to code.

append 'COMMIT WORK.' to code.

concatenate '''' 'DDIF_TABL_PUT' '''' into fm.

concatenate 'CALL FUNCTION' fm into tmp separated by space.

append tmp to code.

concatenate 'EXPORTING NAME =' tabname into tmp separated by space.

append tmp to code.

append 'DD02V_WA = TABDEF' to code.

append 'DD09L_WA = TABTECH' to code.

append 'TABLES DD03P_TAB = TABFIELDS' to code.

append 'EXCEPTIONS' to code.

append 'TABL_NOT_FOUND = 1' to code.

append 'NAME_INCONSISTENT = 2' to code.

append 'TABL_INCONSISTENT = 3' to code.

append 'PUT_FAILURE = 4' to code.

append 'PUT_REFUSED = 5' to code.

append 'OTHERS = 6.' to code.

append 'IF SY-SUBRC <> 0.' to code.

append 'MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO' to code.

append 'WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.' to code.

append 'ELSE.' to code.

append 'COMMIT WORK.' to code.

append 'ENDIF.' to code.

concatenate '''' 'DDIF_TABL_ACTIVATE' '''' into fm.

concatenate 'CALL FUNCTION' fm into tmp separated by space.

append tmp to code.

concatenate 'EXPORTING NAME =' tabname into tmp separated by space.

append tmp to code.

append 'EXCEPTIONS' to code.

append 'NOT_FOUND = 1' to code.

append 'PUT_FAILURE = 2' to code.

append 'OTHERS = 3.' to code.

append 'IF SY-SUBRC <> 0.' to code.

append 'MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO' to code.

append 'WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.' to code.

append 'ELSE.' to code.

append 'COMMIT WORK.' to code.

append 'ENDIF.' to code.

concatenate '''' 'TR_TADIR_INTERFACE' '''' into fm.

concatenate '''' name '''' into tabname.

concatenate 'CALL FUNCTION' fm into tmp separated by space.

append tmp to code.

concatenate 'EXPORTING WI_TADIR_OBJ_NAME =' tabname into tmp separated by space.

append tmp to code.

concatenate 'WI_TADIR_OBJECT =' '''' 'TABL' '''' into tmp.

append tmp to code.

concatenate 'WI_TADIR_PGMID =' '''' 'R3TR' '''' into tmp.

append tmp to code.

concatenate 'WI_TADIR_AUTHOR =' '''' user1 '''' into tmp.

append tmp to code.

concatenate 'WI_TADIR_DEVCLASS =' '''' '$TMP' '''' '.' into tmp.

append tmp to code.

append 'IF SY-SUBRC <> 0.' to code.

append 'MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO' to code.

append 'WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.' to code.

append 'ELSE.' to code.

append 'COMMIT WORK.' to code.

append 'ENDIF.' to code.

insert report repname from code.

submit (repname) and return.

free memory.

clear code.

sap_message = 'Table Created. Uploading Data...'.

endfunction.

+++++++++++++++++++++++++++++++++++++++++

report z_bld_struc_bcuser .

types: begin of mystruc,

int_1 type i ,

char_2(13) type c,

char_3(14) type c,

char_4(7) type c,

char_5(10) type c,

char_6(9) type c,

char_7(4) type c,

char_8(38) type c,

end of mystruc.

field-symbols:

<thestruc> type any,

<thefield> type any.

data: delim1 type char1.

data: field_names1 type char1024.

data: data_type1 type char1024.

data: col_width1 type char1024.

data: cols1 type integer.

data: tabline type mystruc.

data: f_dat type char1024.

data: f_name1 type char30.

data: f_type type char2.

data: f_type2 type char10.

data: f_width type char4.

data: f_width_2 type integer.

data: tmp type char10.

data: tabname type char30.

data: tabdef type dd02v.

data: tabtech type dd09l.

data: tabfields type table of dd03p with header line.

data: cntr type integer.

data: user1 type char30.

data: key_done type bool.

data: char_cnt type integer.

data: char_cnt_2 type integer.

data: zaa6 type standard table of mystruc with header line.

import delim1 from memory id'BCUSERB'.

import cols1 from memory id'BCUSERC'.

import field_names1 from memory id'BCUSERD'.

import tabname from memory id'BCUSERE'.

import user1 from memory id'BCUSERF'.

import data_type1 from memory id'BCUSERG'.

import col_width1 from memory id'BCUSERH'.

assign tabline to <thestruc>.

tabdef-tabname = tabname.

tabdef-tabclass ='TRANSP'.

tabdef-ddlanguage = sy-langu.

tabdef-langdep = sy-langu.

tabdef-ddtext ='DYNAMIC TABLE CREATED VIA RFC'.

tabdef-contflag ='C'.

tabtech-tabname = tabname.

tabtech-tabart ='APPL0'.

tabtech-tabkat ='6'.

tabtech-actflag ='X'.

key_done ='N'.

while cols1 > 0.

cntr = cntr + 1.

split field_names1 at delim1 into f_name1 field_names1.

split data_type1 at delim1 into f_type data_type1.

split col_width1 at delim1 into f_width col_width1.

assign component f_name1 of structure <thestruc> to <thefield>.

<thefield> = f_dat.

"================================================

case f_type.

when'C'.

concatenate'CHAR'f_width into tmp.

f_type2 = tmp.

when'I'.

f_type2 ='INTEGER'.

when'D'.

f_type2 ='DATS'.

when'T'.

f_type2 ='TIMS'.

when'F'.

f_type2 ='FLOAT'.

when'P'.

f_type2 ='SRMCURR'.

endcase.

"================================================

clear tabfields.

tabfields-tabname = tabname.

tabfields-fieldname = f_name1.

move f_width to f_width_2.

char_cnt = char_cnt_2 + f_width_2.

if key_done ='N'.

if char_cnt < 120.

tabfields-keyflag ='X'.

char_cnt_2 = char_cnt + f_width_2.

else.

tabfields-keyflag =''.

key_done ='Y'.

endif.

endif.

tabfields-rollname = f_type2.

tabfields-position = cntr.

tabfields-datatype = f_type.

tabfields-leng = f_width.

if f_type ='P'.

tabfields-reftable ='TCURX'.

tabfields-reffield ='CURRKEY'.

endif.

append tabfields.

cols1 = cols1 - 1.

endwhile.

append tabline to zaa6 .

commit work.

call function 'DDIF_TABL_PUT'

exporting

name = 'ZAA6'

dd02v_wa = tabdef

dd09l_wa = tabtech

tables

dd03p_tab = tabfields

exceptions

tabl_not_found = 1

name_inconsistent = 2

tabl_inconsistent = 3

put_failure = 4

put_refused = 5

others = 6.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

else.

commit work.

endif.

call function 'DDIF_TABL_ACTIVATE'

exporting

name = 'ZAA6'

exceptions

not_found = 1

put_failure = 2

others = 3.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

else.

commit work.

endif.

call function 'TR_TADIR_INTERFACE'

exporting

wi_tadir_obj_name = 'ZAA6'

wi_tadir_object

='TABL'

wi_tadir_pgmid

='R3TR'

wi_tadir_author

='BCUSER'

wi_tadir_devclass

='$TMP'.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

else.

commit work.

endif.

Read only

0 Likes
1,031

opps .. forgot this

function z_check_datatype.

*"----


""Local Interface:

*" IMPORTING

*" VALUE(CHAR_LENGTH) TYPE INTEGER DEFAULT 135

*" EXPORTING

*" VALUE(RESULT) TYPE BOOL

*"----


data: wa_dd01l type dd01l.

select single datatype leng

into corresponding fields of wa_dd01l

from dd01l

where datatype eq 'CHAR' and leng eq char_length.

if sy-subrc eq 0.

result = 'Y'.

else.

result = 'N'.

endif.

endfunction.

Read only

Former Member
0 Likes
1,032

Hello David,

You are looking at the domain table DD01L. Your selection provides you with 12 different domains. One of them is CHAR23. And you are constructing a line like

data: a type CHAR23.

CHAR23 has to be a Data Element!

And the correlation between Domain and Data Element can be viewed in table DD04L. In this table you will find that none of the previously selected 12 domains does have a data element CHAR23. Unfortunately all other domains do have an appropriate Data Element; CHAR22, CHAR21, CHAR20,.....CHAR2, CHAR1. CHAR24, CHAR25 ..... exists again.

Result:

CHAR23 is missing in the Data element table DD04L.

You have to build in a different check, i.e. a modification of the FM z_check_datatype is required. Instead of DD01L, DD04L should be used.

Hope this helps,

Heinz

Read only

Former Member
0 Likes
1,031

Hello David,

Additional thought: why you don't use TYPE STRING?

Let the sun shine,

Heinz

Read only

0 Likes
1,031

THANKS Heize ..

You can probably tell from my coding and naive questions, I'm new to this. I've modified my Z_CHECK_DATATYPE as shown below. This seems to work ..

With regard to your query as to why I'm not using strings ..

Z_Create_Table is an RFC, unfortunately TYPE STRING is unsupported, believe me I wish it were.

I suppose the ultimate fix would be for me to define a new TYPE, but as I review the contents of DD01L, there seems to be an incredible amount of redundancy, just trying to prevent the addition of more glut.

THANKS again for your assist .. Dave

function z_check_datatype.

*"----


""Local Interface:

*" IMPORTING

*" VALUE(CHAR_LENGTH) TYPE INTEGER DEFAULT 23

*" EXPORTING

*" VALUE(RESULT) TYPE BOOL

*"----


data: wa_dd04l type dd04l.

data: roll type char30.

data: tmp type char5.

move char_length to tmp.

condense tmp.

concatenate 'CHAR' tmp into roll.

select single rollname datatype leng lowercase

into corresponding fields of wa_dd04l

from dd04l

where rollname eq roll and datatype eq 'CHAR' and leng eq char_length and lowercase eq ''.

if sy-subrc eq 0.

result = 'Y'.

else.

result = 'N'.

endif.

endfunction.