วันพฤหัสบดีที่ 23 กันยายน พ.ศ. 2553

ABAP Excel ฉึก ฉึก : Include ZGEXCEL02

*&---------------------------------------------------------------------*
*&  Include           ZGEXCEL02
*&---------------------------------------------------------------------*
form  table.
  gi_excel-line = '<table>'.
  append gi_excel.
endform.                    "TR

*&---------------------------------------------------------------------*
*&      Form  endTABLE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form  endtable.
  gi_excel-line = '</table>'.
  append gi_excel.
endform.                    "TR

*&---------------------------------------------------------------------*
*&      Form  TR
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form  tr .
*  <tr height=28 style='height:21.0pt'  >
  gi_excel-line = '<tr height=28>' .
  append gi_excel.
endform.                    "TR
*&---------------------------------------------------------------------*
*&      Form  TR
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form  tr_h using hight .
*  <tr height=28 style='height:21.0pt'  >
*  GI_EXCEL-LINE = '<tr height=28>' .
  concatenate '<tr height=' hight '>' into gi_excel-line.
  append gi_excel.
endform.                    "TR
*&---------------------------------------------------------------------*
*&      Form  ENDTR
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form endtr.
  gi_excel-line = '</tr>'.
  append gi_excel.
endform.                    "ENDTR

*&---------------------------------------------------------------------*
*&      Form  TD_DESC
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form td using style align col row bgcolor ttype text
        font structure zfont. 
 
  data : lv_class type string,
         lv_align  type string,
         lv_col   type string,
         lv_row   type string,
         lv_bg    type string,
         lv_type type string,
         lv_text type string,
         lv_nnum type p decimals 2,
         lv_xnum type string,
         lv_date type string,
         lv_xdate type string.
  data : lv_size type string,
         lv_color type string,
         lv_face type string,
         lv_td type string,
         lv_etd type string.

  if not style is initial.
    concatenate 'class=' style into lv_class.
  endif.
  if not align is initial.
    concatenate 'style=text-align:' align into lv_align.
  endif.
  if not col is initial.
    concatenate 'colspan=' col into lv_col.
  endif.
  if not row is initial.
    concatenate 'rowspan=' row into lv_row.
  endif.
  if not bgcolor is initial.
    concatenate 'background=' bgcolor into lv_bg.
  endif.
*  case TTYPE
  if ttype = 'NUM' or ttype = 'num'.
    lv_type = 'X:num'.
    lv_nnum = text.
    if lv_nnum < 0.
      lv_nnum = lv_nnum * -1.
      lv_xnum = lv_nnum.
*    write: LV_NNUM TO LV_XNUM.
      concatenate  '-' lv_xnum  into lv_xnum.
    else.
      lv_xnum = lv_nnum.
      condense lv_xnum.
    endif.
    concatenate lv_type '=' text-t02 lv_xnum text-t02
    into lv_type.
    lv_text = lv_xnum.

  elseif ttype = 'date' or ttype = 'DATE'.
    lv_type = 'X:String'.
    lv_date = text.

    if lv_date is not initial.
      concatenate lv_date+6(2'.' lv_date+4(2'.' lv_date+0(4into lv_xdate.
    endif.
    if lv_xdate is initial or lv_xdate = '00.00.0000'.
      lv_text = '&nbsp;'.
    else.
      lv_text = lv_xdate.
    endif.
  else.
    lv_type = 'X:String'.
    if text is initial.
      lv_text = '&nbsp;'.
    else.
      lv_text = text.
    endif.
  endif.


  if not font is initial.
    if not font-size is initial.
      concatenate 'size=' font-size into lv_size.
    endif.
    if not font-color is initial.
      concatenate 'color=' font-color into lv_color.
    endif.
    if not font-face is initial.
      concatenate 'face=' font-face into lv_face.
    endif.
    if not font-italic is initial.
      concatenate '<I>' lv_text '</I>' into lv_text.
    endif.
    if not font-bold is initial.
      concatenate '<B>' lv_text '</B>' into lv_text.
    endif.


    concatenate '<font' lv_size lv_color lv_face '>' lv_text '</font>'
    into lv_text.
  endif.

  concatenate '<td' lv_class lv_align lv_col lv_row lv_bg lv_type '>' lv_text '</td>'
  into gi_excel-line separated by space.

  append gi_excel.
endform.                    "TD_DESC


*&---------------------------------------------------------------------*
*&      Form  TD2
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->STYLE      text
*      -->ALIGN      text
*      -->WIDTH      text
*      -->COL        text
*      -->ROW        text
*      -->BGCOLOR    text
*      -->TTYPE      text
*      -->TEXT       text
*      -->FONT       text
*----------------------------------------------------------------------*
form td2 using style align width col row bgcolor ttype text
        font structure zfont.



*  <td class=xl49 align=left style='height:21.0pt'>ทดสอบ</td>
  data : lv_class type string,
         lv_align  type string,
         lv_col   type string,
         lv_row   type string,
         lv_bg    type string,
         lv_type type string,
         lv_width type string,
         lv_text type string,
         lv_nnum type p decimals 2,
         lv_xnum type string,
         lv_date type string,
         lv_xdate type string.
  data : lv_size type string,
         lv_color type string,
         lv_face type string,
         lv_td type string,
         lv_etd type string.



  if not style is initial.
    concatenate 'class=' style into lv_class.
  endif.
  if not align is initial.
    concatenate 'style=text-align:' align into lv_align.
  endif.
  if not width is initial.
    concatenate 'width=' width into lv_width.
  endif.
  if not col is initial.
    concatenate 'colspan=' col into lv_col.
  endif.
  if not row is initial.
    concatenate 'rowspan=' row into lv_row.
  endif.
  if not bgcolor is initial.
    concatenate 'background=' bgcolor into lv_bg.
  endif.
*  case TTYPE
  if ttype = 'NUM' or ttype = 'num'.
    lv_type = 'X:num'.
    lv_nnum = text.
    if lv_nnum < 0.
      lv_nnum = lv_nnum * -1.
      lv_xnum = lv_nnum.

      concatenate  '-' lv_xnum  into lv_xnum.
    else.
      lv_xnum = lv_nnum.
      condense lv_xnum.
    endif.
    concatenate lv_type '=' text-t02 lv_xnum text-t02
    into lv_type.
    lv_text = lv_xnum.

  elseif ttype = 'date' or ttype = 'DATE'.
    lv_type = 'X:String'.
    lv_date = text.
    if lv_date is not initial.
      concatenate lv_date+6(2'.' lv_date+4(2'.' lv_date+0(4into lv_xdate.
    endif.
    if lv_xdate is initial or lv_xdate = '00.00.0000'.
      lv_text = '&nbsp;'.
    else.
      lv_text = lv_xdate.
    endif.

  else.
    lv_type = 'X:String'.
    if text is initial.
      lv_text = '&nbsp;'.
    else.
      lv_text = text.
    endif.
  endif.


  if not font is initial.
    if not font-size is initial.
      concatenate 'size=' font-size into lv_size.
    endif.
    if not font-color is initial.
      concatenate 'color=' font-color into lv_color.
    endif.
    if not font-face is initial.
      concatenate 'face=' font-face into lv_face.
    endif.
    if not font-italic is initial.
      concatenate '<I>' lv_text '</I>' into lv_text.
    endif.
    if not font-bold is initial.
      concatenate '<B>' lv_text '</B>' into lv_text.
    endif.


    concatenate '<font' lv_size lv_color lv_face '>' lv_text '</font>'
    into lv_text.
  endif.

  concatenate '<td' lv_class lv_align lv_width lv_col lv_row lv_bg lv_type '>' lv_text '</td>'
  into gi_excel-line separated by space.

  append gi_excel.
endform.                    "TD_DESC

*&---------------------------------------------------------------------*
*&      Form  TD3
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->STYLE      text
*      -->ALIGN      text
*      -->WIDTH      text
*      -->COL        text
*      -->ROW        text
*      -->BGCOLOR    text
*      -->TTYPE      text
*      -->FORMAT     text
*      -->TEXT       text
*      -->FONT       text
*----------------------------------------------------------------------*
form td3 using style align width col row bgcolor ttype format text
        font structure zfont.



*  <td class=xl49 align=left style='height:21.0pt'>ทดสอบ</td>
  data : lv_class type string,
         lv_align  type string,
         lv_col   type string,
         lv_row   type string,
         lv_bg    type string,
         lv_format type string,
         lv_type type string,
         lv_width type string,
         lv_text type string,
         lv_nnum(16type p decimals 2,
         lv_xnum type string,
         lv_date type string,
         lv_xdate type string,
         lv_time type string,
         lv_xtime type char10.
  data : lv_size type string,
         lv_color type string,
         lv_face type string,
         lv_td type string,
         lv_etd type string.



  if not style is initial.
    concatenate 'class=' style into lv_class.
  endif.
  if not align is initial.
    concatenate 'style=text-align:' align into lv_align.
  endif.
  if not width is initial.
    concatenate 'width=' width into lv_width.
  endif.
  if not col is initial.
    concatenate 'colspan=' col into lv_col.
  endif.
  if not row is initial.
    concatenate 'rowspan=' row into lv_row.
  endif.
  if not bgcolor is initial.
    concatenate 'style=background-color:' bgcolor into lv_bg.
  endif.
*  case TTYPE
  if ttype = 'NUM' or ttype = 'num'.
    lv_type = 'X:num'.
    lv_nnum = text.
    if lv_nnum < 0.
      lv_nnum = lv_nnum * -1.
      lv_xnum = lv_nnum.
*    write: LV_NNUM TO LV_XNUM.
      concatenate  '-' lv_xnum  into lv_xnum.
      condense lv_xnum.
    else.
      lv_xnum = lv_nnum.
      condense lv_xnum.
    endif.
    concatenate lv_type '=' '"' lv_xnum '"'
    into lv_type.
    lv_text = lv_xnum.

  elseif ttype = 'date' or ttype = 'DATE'.
    lv_type = 'X:String'.
    lv_date = text.
    concatenate lv_date+6(2'.' lv_date+4(2'.' lv_date+0(4into lv_xdate.
    if lv_xdate is initial or lv_xdate = '00.00.0000'.
      lv_text = '&nbsp;'.
    else.
      lv_text = lv_xdate.
    endif.
  elseif ttype = 'time' or ttype = 'TIME'.
    lv_type = 'X:Num'.
    lv_time = text.

    if lv_time is initial or lv_time = '000000'.
      lv_text = '&nbsp;'.
    else.
      write: lv_time to lv_xtime using edit mask '__:__:__'.
      lv_text = lv_xtime.
    endif.
  else.
    lv_type = 'X:String'.
    if text is initial.
      lv_text = '&nbsp;'.
    else.
      lv_text = text.
    endif.
  endif.
  if  not format is initial.
    concatenate 'style=mso-number-format:' format into lv_format.
  endif.

  if not font is initial.
    if not font-size is initial.
      concatenate 'size=' font-size into lv_size.
    endif.
    if not font-color is initial.
      concatenate 'style=color:' font-color into lv_color.
    endif.
    if not font-face is initial.
      concatenate 'face=' font-face into lv_face.
    endif.
*    color:red;
    if not font-italic is initial.
      concatenate '<I>' lv_text '</I>' into lv_text.
    endif.
    if not font-bold is initial.
      concatenate '<B>' lv_text '</B>' into lv_text.
    endif.


    concatenate '<font' lv_size  lv_face '>' lv_text '</font>'
    into lv_text.
  endif.

  concatenate '<td' lv_class lv_align lv_width lv_col lv_row lv_bg lv_type lv_format lv_color'>' lv_text '</td>'
  into gi_excel-line separated by space.

  append gi_excel.
endform.                    "TD_DESC

*&---------------------------------------------------------------------*
*&      Form  td3_1
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->STYLE      text
*      -->ALIGN      text
*      -->WIDTH      text
*      -->COL        text
*      -->ROW        text
*      -->BGCOLOR    text
*      -->TTYPE      text
*      -->FORMAT     text
*      -->TEXT       text
*      -->FONT       text
*----------------------------------------------------------------------*
form td3_1 using style align width col row bgcolor ttype format text
        font structure zfont.

  data : lv_class type string,
         lv_align  type string,
         lv_col   type string,
         lv_row   type string,
         lv_bg    type string,
         lv_format type string,
         lv_type type string,
         lv_width type string,
         lv_text type string,
         lv_nnum(16type p decimals 3,
         lv_xnum type string,
         lv_date type string,
         lv_xdate type string,
         lv_time type string,
         lv_xtime type char10.
  data : lv_size type string,
         lv_color type string,
         lv_face type string,
         lv_td type string,
         lv_etd type string.



  if not style is initial.
    concatenate 'class=' style into lv_class.
  endif.
  if not align is initial.
    concatenate 'style=text-align:' align into lv_align.
  endif.
  if not width is initial.
    concatenate 'width=' width into lv_width.
  endif.
  if not col is initial.
    concatenate 'colspan=' col into lv_col.
  endif.
  if not row is initial.
    concatenate 'rowspan=' row into lv_row.
  endif.
  if not bgcolor is initial.
    concatenate 'style=background-color:' bgcolor into lv_bg.
  endif.
*  case TTYPE
  if ttype = 'NUM' or ttype = 'num'.
    lv_type = 'X:num'.
    lv_nnum = text.
    if lv_nnum < 0.
      lv_nnum = lv_nnum * -1.
      lv_xnum = lv_nnum.

      concatenate  '-' lv_xnum  into lv_xnum.
      condense lv_xnum.
    else.
      lv_xnum = lv_nnum.
      condense lv_xnum.
    endif.
    concatenate lv_type '=' '"' lv_xnum '"'
    into lv_type.
    lv_text = lv_xnum.

  elseif ttype = 'date' or ttype = 'DATE'.
    lv_type = 'X:String'.
    lv_date = text.
    concatenate lv_date+6(2'.' lv_date+4(2'.' lv_date+0(4into lv_xdate.
    if lv_xdate is initial or lv_xdate = '00.00.0000'.
      lv_text = '&nbsp;'.
    else.
      lv_text = lv_xdate.
    endif.
  elseif ttype = 'time' or ttype = 'TIME'.
    lv_type = 'X:Num'.
    lv_time = text.

    if lv_time is initial or lv_time = '000000'.
      lv_text = '&nbsp;'.
    else.
      write: lv_time to lv_xtime using edit mask '__:__:__'.
      lv_text = lv_xtime.
    endif.
  else.
    lv_type = 'X:String'.
    if text is initial.
      lv_text = '&nbsp;'.
    else.
      lv_text = text.
    endif.
  endif.
  if  not format is initial.
    lv_format = 'style=mso-number-format:"0\.0000"' .
  endif.

  if not font is initial.
    if not font-size is initial.
      concatenate 'size=' font-size into lv_size.
    endif.
    if not font-color is initial.
      concatenate 'style=color:' font-color into lv_color.
    endif.
    if not font-face is initial.
      concatenate 'face=' font-face into lv_face.
    endif.
*    color:red;
    if not font-italic is initial.
      concatenate '<I>' lv_text '</I>' into lv_text.
    endif.
    if not font-bold is initial.
      concatenate '<B>' lv_text '</B>' into lv_text.
    endif.


    concatenate '<font' lv_size  lv_face '>' lv_text '</font>'
    into lv_text.
  endif.

  concatenate '<td' lv_class lv_align lv_width lv_col lv_row lv_bg lv_type lv_format lv_color'>' lv_text '</td>'
  into gi_excel-line separated by space.

  append gi_excel.
endform.                    "TD_DESC
*&---------------------------------------------------------------------*
*&      Form  TD3
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->STYLE      text
*      -->ALIGN      text
*      -->WIDTH      text
*      -->COL        text
*      -->ROW        text
*      -->BGCOLOR    text
*      -->TTYPE      text
*      -->FORMAT     text
*      -->TEXT       text
*      -->FONT       text
*----------------------------------------------------------------------*
form td3_3 using style align width col row bgcolor ttype format text
        font structure zfont.



*  <td class=xl49 align=left style='height:21.0pt'>ทดสอบ</td>
  data : lv_class type string,
         lv_align  type string,
         lv_col   type string,
         lv_row   type string,
         lv_bg    type string,
         lv_format type string,
         lv_type type string,
         lv_width type string,
         lv_text type string,
         lv_nnum(15type p decimals 3,
         lv_xnum type string,
         lv_date type string,
         lv_xdate type string.
  data : lv_size type string,
         lv_color type string,
         lv_face type string,
         lv_td type string,
         lv_etd type string.



  if not style is initial.
    concatenate 'class=' style into lv_class.
  endif.
  if not align is initial.
    concatenate 'style=text-align:' align into lv_align.
  endif.
  if not width is initial.
    concatenate 'width=' width into lv_width.
  endif.
  if not col is initial.
    concatenate 'colspan=' col into lv_col.
  endif.
  if not row is initial.
    concatenate 'rowspan=' row into lv_row.
  endif.
  if not bgcolor is initial.
    concatenate 'style=background-color:' bgcolor into lv_bg.
  endif.
*  case TTYPE
  if ttype = 'NUM' or ttype = 'num'.
    lv_type = 'X:num'.
    lv_nnum = text.
    if lv_nnum < 0.
      lv_nnum = lv_nnum * -1.
      lv_xnum = lv_nnum.
*    write: LV_NNUM TO LV_XNUM.
      concatenate  '-' lv_xnum  into lv_xnum.
      condense lv_xnum.
    else.
      lv_xnum = lv_nnum.
      condense lv_xnum.
    endif.
    concatenate lv_type '=' '"' lv_xnum '"'
    into lv_type.
    lv_text = lv_xnum.

  elseif ttype = 'date' or ttype = 'DATE'.
    lv_type = 'X:String'.
    lv_date = text.
    concatenate lv_date+6(2'.' lv_date+4(2'.' lv_date+0(4into lv_xdate.
    if lv_xdate is initial or lv_xdate = '00.00.0000'.
      lv_text = '&nbsp;'.
    else.
      lv_text = lv_xdate.
    endif.
  else.
    lv_type = 'X:String'.
    if text is initial.
      lv_text = '&nbsp;'.
    else.
      lv_text = text.
    endif.
  endif.
  if  not format is initial.
    concatenate 'style=mso-number-format:' format into lv_format.
  endif.

  if not font is initial.
    if not font-size is initial.
      concatenate 'size=' font-size into lv_size.
    endif.
    if not font-color is initial.
      concatenate 'style=color:' font-color into lv_color.
    endif.
    if not font-face is initial.
      concatenate 'face=' font-face into lv_face.
    endif.
*    color:red;
    if not font-italic is initial.
      concatenate '<I>' lv_text '</I>' into lv_text.
    endif.
    if not font-bold is initial.
      concatenate '<B>' lv_text '</B>' into lv_text.
    endif.


    concatenate '<font' lv_size  lv_face '>' lv_text '</font>'
    into lv_text.
  endif.

  concatenate '<td' lv_class lv_align lv_width lv_col lv_row lv_bg lv_type lv_format lv_color'>' lv_text '</td>'
  into gi_excel-line separated by space.
  append gi_excel.
endform.                    "TD_DESC

ไม่มีความคิดเห็น:

แสดงความคิดเห็น