Application Development 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: 

Infotype 1002 Job Description Upload.

0 Kudos
513
I need to maintain Job Descriptions in Infotype 1002. I have succesfully uploaded the description but it's alignment is an issue for me as it is breaking the word and going to next line. My requirement is that no word should break when uploading the long text.I have read Excel file into internal table. Then I have used RSDG_WORD_WRAP / IQAPI_WORD_WRAP / RKD_WORD_WRAP . All these function modules are not serving the purpose. I dont want to use seperator just need it done on the line size. After this i use FM RH_OBJECT_DESCRIPTION_WRITE and upload the data from excel to IT1002.
DATA:
  it_ptxt1002  TYPE STANDARD TABLE OF zpt1002 WITH HEADER LINE, "TABLES PARAM
  wa_ptxt1002  LIKE LINE OF it_ptxt1002.
DATA:
  ld_plvar TYPE hrp1000-plvar,
  ld_otype TYPE hrp1000-otype,
  ld_objid TYPE hrp1000-objid,
  ld_begda TYPE p1000-begda,
  ld_endda TYPE p1000-endda,
  ld_subty TYPE p1002-subty,
  ld_duty   TYPE sy-input,
  ld_vtask TYPE hrrhap-vtask.
PARAMETERS : p_infile LIKE rlgrap-filename.
INCLUDE bdcrecx1.
DATA: itab LIKE zalsmex_tabline OCCURS 0 WITH HEADER LINE.
DATA :
       obj(8) TYPE i.
TYPES: BEGIN OF t_record,
         plan_ver    LIKE itab-value,
         otype       LIKE itab-value,
         objid       LIKE itab-value,
         infotype    LIKE itab-value,
         subtype     LIKE itab-value,
         plan_status LIKE itab-value,
         val_begin   LIKE itab-value,
         val_end     LIKE itab-value,
         text        LIKE itab-value,
         row         TYPE i,
         tsize       TYPE i,
       END OF t_record.
DATA: i_tab          TYPE STANDARD TABLE OF t_record  INITIAL SIZE 0,
      it_lines       LIKE STANDARD TABLE OF tline WITH HEADER LINE,
      it_text_header LIKE STANDARD TABLE OF thead WITH HEADER LINE.
DATA: it_record TYPE STANDARD TABLE OF t_record INITIAL SIZE 0,
      wa_record TYPE t_record.
DATA: gd_currentrow TYPE i.
DATA: off     TYPE i VALUE '0',
      p_error TYPE  sy-lisel,
      len     TYPE i,
      beg     TYPE dats,
      end     TYPE dats.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_infile .
  CALL FUNCTION 'F4_FILENAME'
    IMPORTING
      file_name = p_infile.
START-OF-SELECTION.
  CALL FUNCTION 'ZALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
      filename                = p_infile
      i_begin_col             = '1'
      i_begin_row             = '2'  "require headings
      i_end_col               = '30'
      i_end_row               = '50000'
    TABLES
      intern                  = itab
    EXCEPTIONS
      inconsistent_parameters = 1
      upload_ole              = 2
      OTHERS                 = 3.
  IF sy-subrc <> 0.
    MESSAGE e010(zz) WITH TEXT-001. "Problem uploading Excel Spreadsheet
  ENDIF.
* Sort table by rows and colums
  SORT itab BY row1 col1.
* Get first row retrieved
  READ TABLE itab INDEX 1.
* Set first row retrieved to current row
  gd_currentrow = itab-row1.
  LOOP AT itab.
*   Reset values for next row
    IF itab-row1 NE gd_currentrow.
      APPEND wa_record TO it_record.
      CLEAR wa_record.
      gd_currentrow = itab-row1.
    ENDIF.
    CASE itab-col1.
     WHEN '0001'.
        wa_record-plan_ver = itab-value.
      WHEN '0002'.
        wa_record-otype = itab-value.
      WHEN '0003'.
        wa_record-objid   = itab-value.
      WHEN '0004'.
        wa_record-infotype   = itab-value.
      WHEN '0005'.
        wa_record-subtype = itab-value.
      WHEN '0006'.
        wa_record-plan_status = itab-value.
      WHEN '0007'.
        wa_record-val_begin = itab-value.
      WHEN '0008'.
        wa_record-val_end = itab-value.
      WHEN '0009'.
        wa_record-text = itab-value.
    ENDCASE.
    AT END OF row1.
      wa_record-tsize = strlen( wa_record-text ) .        " “Finding String Length using STRLEN
      wa_record-row = itab-row1 .               "   “Adding Current Row Num into Internal table
      APPEND wa_record TO i_tab.
      CLEAR wa_record .
    ENDAT.
  ENDLOOP.
START-OF-SELECTION.
  LOOP AT i_tab INTO wa_record.
CALL FUNCTION 'RSDG_WORD_WRAP'
  EXPORTING
    textline                  = wa_record-text
   DELIMITER                 = '.'
   OUTPUTLEN                 = 72
* IMPORTING
*   OUT_LINE1                 =
*   OUT_LINE2                 =
*   OUT_LINE3                 =
 TABLES
   OUT_LINES                 = it_ptxt1002
* EXCEPTIONS
*   OUTPUTLEN_TOO_LARGE       = 1
*   OTHERS                    = 2 .
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
    CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
      EXPORTING
        date_external = wa_record-val_begin
*       ACCEPT_INITIAL_DATE            =
      IMPORTING
        date_internal = beg
* EXCEPTIONS
*      DATE_EXTERNAL_IS_INVALID       = 1
*       OTHERS        = 2
      .
    IF sy-subrc <> 0.
* Implement suitable error handling here
    ENDIF.
    CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
      EXPORTING
        date_external = wa_record-val_end
*       ACCEPT_INITIAL_DATE            =
      IMPORTING
        date_internal = end
* EXCEPTIONS
*       DATE_EXTERNAL_IS_INVALID       = 1
*       OTHERS        = 2 .
    IF sy-subrc <> 0.
* Implement suitable error handling here
    ENDIF.
    ld_plvar = wa_record-plan_ver.
    ld_otype = wa_record-otype.
    ld_objid = wa_record-objid.
    ld_subty = wa_record-subtype.
    CALL FUNCTION 'RH_OBJECT_DESCRIPTION_WRITE'
      EXPORTING
        langu                = sy-langu
        plvar                = ld_plvar "wa_record-plan_ver
        otype                = ld_otype "wa_record-otype
        objid                = ld_objid "wa_record-objid
        begda                = beg "'19000101'
        endda                = end "'99991231'
        subty                = ld_subty "wa_record-subtype "'0001'
        duty                 = ' '
        vtask                = 'D'
      TABLES
        ptxt1002             = it_ptxt1002
      EXCEPTIONS
        object_not_found     = 1
        description_required = 2
        no_authority         = 3
        error_during_insert  = 4
        invalid_date         = 5
        undefined            = 6
        OTHERS               = 7..
    CLEAR : it_ptxt1002 , beg , end , ld_plvar , ld_otype , ld_objid , ld_subty.
  ENDLOOP.
1 ACCEPTED SOLUTION

0 Kudos
187

I have Highlighted issues with red circles.
As you can see at the end of point number 2 Assembly is break down in half. and in point 4 cabinet is incomplete.

3 REPLIES 3

0 Kudos
187

Dear Attique

Can you please share the paragraph which you are trying to upload and in which infotype.

0 Kudos
187

pp02-fields.txt
sarfrazharoon I have uploaded screen shot as well as converted text file.
I am trying to upload Job Description in IT1002 & Subtype 4004.

0 Kudos
188

I have Highlighted issues with red circles.
As you can see at the end of point number 2 Assembly is break down in half. and in point 4 cabinet is incomplete.